Skycatch / node-box

Box API client for Node.JS
MIT License
21 stars 19 forks source link

Node-box file upload with absolute internet url #10

Open Shahbazgit opened 9 years ago

Shahbazgit commented 9 years ago

Hi,

I want to upload a file via absolute internet url like 'http://mydomain//myfile.jpg' but i am getting an error 'unhandled stream error in pipe'

Can you please guide me how to achieve this? How can i upload a file present over the internet.

Waiting for your response, Shahbaz

srt32 commented 9 years ago

Are you using the Files.upload function (found here: https://github.com/Skycatch/node-box/blob/master/lib/index.js#L133)?

That function makes a multipart POST to https://upload.box.com/api/2.0/files/content and Box's docs expect a file. I don't believe Box's API supports fetching files from arbitrary URL's.

EDIT: from the same docs referenced above, a manual cURL request to this endpoint would look like the below:

curl https://upload.box.com/api/2.0/files/content \
  -H "Authorization: Bearer ACCESS_TOKEN" -X POST \
  -F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}' \
  -F file=@myfile.jpg
srt32 commented 9 years ago

ping @Shahbazgit, did you figure out your issue or did my earlier response (https://github.com/Skycatch/node-box/issues/10#issuecomment-120988874) help at all?