Page 1 of 1

Upload a document to a server

Posted: Thu Sep 12, 2019 10:21 am
by jtrolle
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

Re: Upload a document to a server

Posted: Fri Sep 13, 2019 11:27 pm
by Mark
Is httpsApiClient_sendRequest using libURLMultipartFormData? If not, that could be the problem.

Re: Upload a document to a server

Posted: Sat Sep 14, 2019 12:20 am
by jtrolle
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...??