refactor: Upload file to storage, and then pass attachmentId to collections.import

This avoids having large file uploads going directly to the server and allows us to fetch it async into a worker process
This commit is contained in:
Tom Moor
2021-02-18 22:36:07 -08:00
parent 568e271738
commit df233c95a9
12 changed files with 70 additions and 54 deletions

View File

@ -39,11 +39,13 @@ export const uploadFile = async (
formData.append("file", file);
}
await fetch(data.uploadUrl, {
const uploadResponse = await fetch(data.uploadUrl, {
method: "post",
body: formData,
});
invariant(uploadResponse.ok, "Upload failed, try again?");
return attachment;
};