forge-php-client icon indicating copy to clipboard operation
forge-php-client copied to clipboard

uploadObject method not working

Open augustogoncalves opened this issue 8 years ago • 11 comments

It seems it's converting the body/file and causing error 504

augustogoncalves avatar Jul 20 '17 18:07 augustogoncalves

We had this issue using the ObjectsApi#uploadObject method. The issue was related with line #137 on ApiClient file, trying to convert the body(file) to JSON.

luiztiago avatar Jul 21 '17 15:07 luiztiago

I encountered the same problem. The documentation specify passing the file path to the uploadObject() function. When you do this, it does not attempt to json_encode it in line 136, since it's a string, but the upload times out with a 504 response, since the specified payload size is bigger than the actual content sent. The work around I implemented was changing line #196 from: curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); to: curl_setopt($curl, CURLOPT_POSTFIELDS, file_get_contents($postData));

hishamyounis avatar Aug 02 '17 20:08 hishamyounis

When is this going to be fixed? It's a small patch right. Still having trouble with this!

I can make a pull request if needed, or is this problem bigger then that single line?

melledijkstra avatar Jan 04 '18 11:01 melledijkstra

Unfortunately, we are no longer maintaining this SDK. If you send a PR, we would be happy to merge it.

ido567 avatar Jan 07 '18 10:01 ido567

@ido567 That's too bad, well I fixed it with https://github.com/cweagans/composer-patches (for others having this problem). If I have some time I will send a PR. Thanks anyway! ;)

melledijkstra avatar Jan 07 '18 10:01 melledijkstra

@MelleDijkstra If you are still using this ;)

It seems it is just the parameter suggestion in the docblock is wrong, uploadObject does not need a SplFileObject but just the file content is fine.

tuimz avatar May 16 '18 12:05 tuimz

@tuimz Ahh, so a patch wasn't actually needed just pass file_get_contents() straight into the function. well... the patch works anyways 😋. Thanks!

melledijkstra avatar May 16 '18 18:05 melledijkstra

Hi @augustogoncalves I have submitted a PR wich resolves this issue. Could you take a look?

tuimz avatar May 22 '18 08:05 tuimz

@tuimz Thanks for your PRs, I will help Augusto to maintain the SDK, I am checking your PR but my access seems not enough to approve that, working on that now.

JohnOnSoftware avatar May 23 '18 23:05 JohnOnSoftware

This bug is still present... I also had to insert following lines to get rid of a http 504 error:

curl_setopt($curl, CURLOPT_FORBID_REUSE, 1); curl_setopt($curl, CURLOPT_ENCODING , "");

swalter88 avatar Jun 11 '18 08:06 swalter88

The 504 problem still occurs, how can I solve it?

Dshufeng avatar Aug 20 '20 06:08 Dshufeng