Upload a document to a server

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
jtrolle
Posts: 5
Joined: Thu Sep 05, 2019 9:31 pm

Upload a document to a server

Post by jtrolle » Thu Sep 12, 2019 10:21 am

Hello ...
I am working on a project, which has a section to upload any type of documents.
On my server, I have a document table, with a blob type field.
I have managed to upload any type of document, smaller than 1 Mb, and then be able to download and view it.

My problem is that when I upload a document with a size larger than 1MB, the post function returns this error:
-tsneterr: (28) Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds

This is my code on the upload document button:

Code: Select all

on mouseUp
     answer file "Seleccione archivo." with specialFolderPath("Desktop") 
     put it into tPath
     put url ("binfile:" & tPath) into tBinaryData
     put base64Encode(tBinaryData) into tDocumentBase64
     put coreUpdateRelatedRecords("documents", tRecordId, tDatagridData) into tResult
end mouseUp

function coreUpdateRelatedRecords pRelatedTable, pRelatedRecordId, pDataArray
    put "updateRecord_" & pRelatedTable & "_" & pRelatedRecordId into tTask
    put httpsApiClient_sendRequest(tProfile, tTask, pDataArray) into tResponse
end coreUpdateRelatedRecords

The function httpsApiClient_sendRequest is from a library called libHttpsApiClient

I publish a piece of the code of the function httpsApiClient_sendRequest, which is the part where the post is made to the url, and it returns the error

Code: Select all

function httpsApiClient_sendRequest pProfile, pTask, pDataArray
   ....................................
   ..................
   ............
   post compress(tStringToPost) to url s["profiles"][pProfile]["api_url"]
   put it into tResponseJson  
   put the result into tResult
   ...............
   .......................
   ...............................
end httpsApiClient_sendRequest

in the response, this error appears:
-tsneterr: (28) Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds



My question is this . Im doing the right way to upload a file ..? If its the right way, why cant I upload large files ..?


Thank you very much in advance

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5135
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Upload a document to a server

Post by Mark » Fri Sep 13, 2019 11:27 pm

Is httpsApiClient_sendRequest using libURLMultipartFormData? If not, that could be the problem.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jtrolle
Posts: 5
Joined: Thu Sep 05, 2019 9:31 pm

Re: Upload a document to a server

Post by jtrolle » Sat Sep 14, 2019 12:20 am

Sorry but I do not understand.
I am working with the server (hostm com).
On the server is the .lc file that calls the library (libHttpsApiServer), and in the application I am working with the functions of the library (libHttpsApiClient), to make the posts to the server ....
Is not correct...??

Post Reply

Return to “Internet”