Repository navigation
feat(web): remove upload file limit with rxjs and improve import size - #1743
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
|
The upload notifications don't play along nicely. When uploading some smaller files, the upload notification only appears for a split second. For limiting the concurrency of uploading files, I would like to propose another solution without having to import export const fileUploadHandler = async (
files: File[],
albumId: string | undefined = undefined,
sharedKey: string | undefined = undefined,
onDone?: (id: string) => void
) => {
const concurrency = 2;
const acceptedFiles = files
.filter((file) => {
const assetType = getFileMimeType(file).split('/')[0];
return assetType === 'video' || assetType === 'image';
})
.entries();
// Start new workers up to the set concurrency limit. Each worker will take
// files from the shared acceptedFiles iterator.
const workers = Array<typeof acceptedFiles>(concurrency)
.fill(acceptedFiles)
.map(async (files) => {
for (const [, file] of files) {
await fileUploader(file, albumId, sharedKey, onDone);
}
});
// Wait until all workers have completed.
await Promise.all(workers);
}; |
I was experimenting with removing the setTimeout to remove the finished item from the UI list, so that must be why it flashes for small files. Thank you for the suggestion, I will try it in the code. FYI, I try to use the openapi client to perform the upload action, but the payload somehow indicate the |
|
@michelheusschen FYI, I discussed with the group, and we are going with RxJs route as it is easier to understand, and with tree shaking, we are not loading a lot of code from the library itself. |
|
|
||
| for (const asset of acceptedFile) { | ||
| await fileUploader(asset, albumId, sharedKey, onDone); | ||
| for (const file of acceptedFile) { |
There was a problem hiding this comment.
The lines above this also loop through the list of assets. Can we combine the two loops into one? ie for each asset, get mime type, if true add to files$?
No description provided.