As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
504 Gateway Time-out on uploading file to Kinvey Cloud (PHP, cURL)
T
Tayger
started a topic
over 5 years ago
Hello
I'm working with PHP, sending/retrieving data from my hosted server. I was able to do all CRUD operation with cURL. As already mentioned in another thread I would like to post a complete and working set of all operations. Im nearly done. The last days I have worked to bring up files to the File Storage systems and went through your documentation
I'm able to request an upload URL (no/empty _requiredHeaders list in it). But then trying effectively to upload an image runs into a session timeout after 30 seconds, output:
504 Gateway Time-out
nginx
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
The funny thing: After this I see a proper record in my "Files" area with a "_downloadURL". I even can click the link with the following output:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>
No such object: 4161a22b4be84bb5b6edf024782ddb8d/ceb2301d-3980-476b-37ee-396761610095/116efa46-9031-4462-ba5f-5636d3b6a788
</Details>
</Error>
(Pranav has access to my Kinvey environment, feel free to check it).
After trying different variations of uploading a file using cURL I was checking all threads here and also at Stackoverflow. All nearby answers seems to be several years old and done in different calls. So here 2 examples how I try to upload a file after receiving a the uploadURL:
The problem here: Data must by send in an array but you want to have it sent "raw". I played around here but also didn't work. By saying this: Sending $cfile in the
After the mentioned session timeout I have to close and reopen browser (FF) otherwise the next server operation screws up my browser (blocks forever).
An older way using cURL for upload also runs into a Session Timeout:
I did many abbreviations of the posted examples but after hours I just can't find a proper solution or what I'm doing wrong. Your help would be VERY appreciated. I'm pretty sure the problem is around delivering the file.
Regards
Best Answer
P
Pranav J
said
over 5 years ago
Hello Tayger,
Your reply to this question opened a new forum post. Hence I am copying your reply here to complete the loop:
"Hi
I wrote you this morning concerning fileupload with PHP/cURL. Its not yet published, thats ok. I have found a solution after some more research.
For everyone else who wants to upload files (file storage) by PHP/cURL:
// Upload file to Kinvey File Storage $ch = curl_init ($ch);
curl_setopt( $ch, CURLOPT_PUT, true );
curl_setopt( $ch, CURLOPT_INFILESIZE, <size_of_your_file>);
curl_setopt( $ch, CURLOPT_INFILE, ($in=fopen(<path_with_filename>, 'rb')) ); // b(inary) not mandatory but recommended
// curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Length: " . filesize($myfile)) ); // seems not necessary, covered by CURLOPT_INFILESIZE
curl_setopt( $ch, CURLOPT_HTTPHEADER, []); // Make sure header is empty then if filled by a previous cURL process, otherwise error message
curl_setopt( $ch, CURLOPT_URL, <uploadpath_from_previous_step> );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
print_r ($result); // -> no output (would be nice to have some as confirmation)curl_close ($ch);
This is the only way I could make it work. If a file is uploaded successfully you can click the download link in your Kinvey console (File area) in order to download/watch it.
Regards"
1 Comment
P
Pranav J
said
over 5 years ago
Answer
Hello Tayger,
Your reply to this question opened a new forum post. Hence I am copying your reply here to complete the loop:
"Hi
I wrote you this morning concerning fileupload with PHP/cURL. Its not yet published, thats ok. I have found a solution after some more research.
For everyone else who wants to upload files (file storage) by PHP/cURL:
// Upload file to Kinvey File Storage $ch = curl_init ($ch);
curl_setopt( $ch, CURLOPT_PUT, true );
curl_setopt( $ch, CURLOPT_INFILESIZE, <size_of_your_file>);
curl_setopt( $ch, CURLOPT_INFILE, ($in=fopen(<path_with_filename>, 'rb')) ); // b(inary) not mandatory but recommended
// curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Length: " . filesize($myfile)) ); // seems not necessary, covered by CURLOPT_INFILESIZE
curl_setopt( $ch, CURLOPT_HTTPHEADER, []); // Make sure header is empty then if filled by a previous cURL process, otherwise error message
curl_setopt( $ch, CURLOPT_URL, <uploadpath_from_previous_step> );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
print_r ($result); // -> no output (would be nice to have some as confirmation)curl_close ($ch);
This is the only way I could make it work. If a file is uploaded successfully you can click the download link in your Kinvey console (File area) in order to download/watch it.
Tayger
Hello
I'm working with PHP, sending/retrieving data from my hosted server. I was able to do all CRUD operation with cURL. As already mentioned in another thread I would like to post a complete and working set of all operations. Im nearly done. The last days I have worked to bring up files to the File Storage systems and went through your documentation
I'm able to request an upload URL (no/empty _requiredHeaders list in it). But then trying effectively to upload an image runs into a session timeout after 30 seconds, output:
504 Gateway Time-out
nginx
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
The funny thing: After this I see a proper record in my "Files" area with a "_downloadURL". I even can click the link with the following output:
(Pranav has access to my Kinvey environment, feel free to check it).
After trying different variations of uploading a file using cURL I was checking all threads here and also at Stackoverflow. All nearby answers seems to be several years old and done in different calls. So here 2 examples how I try to upload a file after receiving a the uploadURL:
Parameter sent with upload request:
$uploadurl: https://storage.googleapis.com/4161a22b4be84bb5b6edf024782ddb8d/2bf0d0fe-db88-51e3-b2e5-559cc7e357f9/2bf0d0fe-db88-51e3-b2e5-559cc7e357f9.gif?GoogleAccessId=558440376631@developer.gserviceaccount.com&Expires=1525686153&Signature=NZOCnTWBsJ204Qg2L%2FVgcmcnGPj5tO3ehw5%2Fgg4o2VjrtC118q%2Fd99ehxyFg5RPP89Mghde34g%2Ftt3bEl%2BIIk6aayTlsxkkR%2Frhsu6Z%2BITLTiesxL3ZSbgGIfMbUx8yHDlUsqd2OAGPU1%2BLSZOJsyTg9q6R6bniItKJZTrMckiA%3D
$filepathname: ../gallery/2a3d215c-bc45-41bd-ab0d-08eb07c09b4f/image/2bf0d0fe-db88-51e3-b2e5-559cc7e357f9.gif
$size: 51034
- The user performing all this has the right for all necessary operations)
I have also tried it without option '_requireHeaders' in the header since its displayed as empty array in the return result of the upload request.
The mentioned example is the "modern" way using cURL. There is another function that should be used in relation with
The problem here: Data must by send in an array but you want to have it sent "raw". I played around here but also didn't work. By saying this: Sending $cfile in the
After the mentioned session timeout I have to close and reopen browser (FF) otherwise the next server operation screws up my browser (blocks forever).
An older way using cURL for upload also runs into a Session Timeout:
I did many abbreviations of the posted examples but after hours I just can't find a proper solution or what I'm doing wrong. Your help would be VERY appreciated. I'm pretty sure the problem is around delivering the file.
Regards
Hello Tayger,
Your reply to this question opened a new forum post. Hence I am copying your reply here to complete the loop:
"Hi
I wrote you this morning concerning fileupload with PHP/cURL. Its not yet published, thats ok. I have found a solution after some more research.
For everyone else who wants to upload files (file storage) by PHP/cURL:
This is the only way I could make it work. If a file is uploaded successfully you can click the download link in your Kinvey console (File area) in order to download/watch it.
Regards"
Pranav J
Hello Tayger,
Your reply to this question opened a new forum post. Hence I am copying your reply here to complete the loop:
"Hi
I wrote you this morning concerning fileupload with PHP/cURL. Its not yet published, thats ok. I have found a solution after some more research.
For everyone else who wants to upload files (file storage) by PHP/cURL:
This is the only way I could make it work. If a file is uploaded successfully you can click the download link in your Kinvey console (File area) in order to download/watch it.
Regards"
-
Why am I getting "SignatureDoesNotMatch" error when uploading a file?
-
Why am I getting an "IncompleteRequestBody" error when sending a DELETE request?
-
Is there a default sort order to collections fetched without an explicit sort query?
-
Is it possible to set ACLs on all users so that only administrators can query for users (without dis
-
Flex SDK
-
Query Bug in Backend?
-
Can analytics data be retrieved via Java SDK or REST?
-
Accesing REST API from a server without a user?
-
What json is required to assign a user group either read/write?
-
LDAP Authorization
See all 120 topics