Slow Uploading and Timeout
I have gone through various tutorials, examples, and recommendations, but the SDK upload_large_stream takes forever. I have tested several sizes from 5MB to over 20MB, it takes a very long time or sometimes timeout leaving our users frustrated with the response time. What can I do differently because this has really slowed down the site usage, this happens for both single and multiple file uploads.
This is the code below
let streamUpload = (file) => {
return new Promise((resolve, reject) => {
let stream = v2.uploader.upload_stream(file.options,
(error, result) => {
if (result) {
resolve(result);
} else {
reject(error);
}
},
);
fs.readFile(file.filePath, function(err, buffer) {
if (err) throw err;
streamifier.createReadStream(buffer).pipe(stream);
});
});
};
let setUpFiles = files.map(async (file) => {
return await streamUpload(file);
});
return await Promise.all(setUpFiles);
-
Hi there,
Thank you for reaching out.
I've just tested uploading a 25MB image and the total round trip time took between 25 to 30 seconds which is totally normal for a file of this size.
How long is it taking for your uploads? Could you give us some examples? If your users are receiving a time-out then this would most likely be related to their egress as it takes longer for the data to get to us. Do you have any data on the upload speed of your end-users?
One option you can take is to pass the `async=true` flag during your upload call so as soon as we receive all the data, we will complete the process in the background asynchronously. You will get an initial response saying `pending` and if you have a `notification_url` we will send the complete response there. This may not help if upload speed is the issue but worth a try.
Please let me know if you have any questions.
Kind Regards,
Thomas
Please sign in to leave a comment.
Comments
1 comment