uploadFile API - can't get to upload video file
I am trying to upload into Box a video that is in my storage network. I have the URL to the video file, and am using this code snippet:
var fn = "https://a-long-url.com?param=1&option=you_get_the_idea"; var stream = fs.createReadStream(fn); var folderID = '0'; var p = new Promise( (resolve,reject)=>{ console.log("* Initiating upload: " + fn );
client.files.uploadFile(folderID, 'glenn.mp4', stream) .then( (file)=>{ resolve(file); }, (error) =>{ reject(error); }); }); return p;
But this always creates an error:
Error: form-data: ENOENT: no such file or directory, open 'C:\Users\glenn\Documents\node\myProject\https://a-long-url.com?param=1&option=you_get_the_idea'
It appears that the Box API tries to find the stream based off a home directory path. This won't work for an cloud-based Enterprise upload service. What am I missing here?
-Glenn Inn
-
The error you're seeing does not come from Box, but directly from Node.js — specifically this line:
var stream = fs.createReadStream(fn);
The Node.js fs built-in module is made for filesystem access; if you want to stream the file from a network service you'll need to use something like https.get() instead.
Please sign in to leave a comment.
Comments
1 comment