alex-phillips / clouddrive-php

Amazon Cloud Drive API and CLI for PHP
MIT License
36 stars 9 forks source link

Converted uploadFile to stream the contents, accept resource or string #21

Closed Zn4rK closed 8 years ago

Zn4rK commented 8 years ago

I ran into an issue saying "400 Bad Request" with no message, when trying to upload .cr2-raw files. Renaming them to .jpg worked.

After a whole lot of debugging and research, I found a thread on Amazon's forum, specificing how the multipart should look like; https://forums.developer.amazon.com/forums/thread.jspa?messageID=21591&#21591

So this PR covers that.

During this, I also converted uploadFile to take either a resource or a path, and I'm using stream_get_meta_data to get the path of the stream if it's a stream. I'm also creating the stream early on, since it's being converted on at least two places (Node::overwrite() and CloudDrive->nodeExists()) to streams anyway.

This means that the recent, accepted PR of the streams-branch is kinda obsolete, but I kept the uploadStream()-method in, but converted it to just call uploadFile, so we have nice backwards compatibility.

Zn4rK commented 8 years ago

I was in a hurry earlier, I branched to a feature-branch instead and closed the other PR.

alex-phillips commented 8 years ago

This looks fine to me as far as the streams support.