admin管理员组文章数量:1315288
I've been struggling a lot with the implementation of AWS SDK for S3 in React Native, specially when trying to upload videos to my buckets (+150MB in size), I already tried different ways to read these videos in chunks but had no luck when sending these chunks over to S3 Buckets.
const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB - AWS MultiPart Min Size
const fileStreaming = async (uri) => {
try {
const resp = await fetch(uri);
const reader = await resp.body;
console.log(typeof reader)
const parallelUpload = new Upload({
client: client,
params: {
Bucket: 'example',
Key: 'file-stream-test-2.mp4',
Body: reader,
ContentType: 'video/mp4'
},
queueSize: 4,
partSize: CHUNK_SIZE,
leavePartsOnError: false
});
parallelUpload.on("httpUploadProgress", (progress) => {
console.log(progress);
});
const completeUpload = await parallelUpload.done();
console.log(completeUpload);
} catch(err) {
console.error(err);
}
}
This is one of the methods that I tried but when the upload starts, the UI freezes, but something that is weird is that if I only ready the chunks without sending them to S3 it won't block the UI thread, as well I tried calling an API every time a chunk get's read and the UI never get's frozen.
Do you guys know how can I upload large files without blocking UI?
My UI get's blocked during the upload process but only when using AWS SDK, if I call an API every time a chunks is read, the UI still working as expected.
本文标签: amazon web servicesHow to upload a file without blocking the UIStack Overflow
版权声明:本文标题:amazon web services - How to upload a file without blocking the UI? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741980423a2408364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论