#upload files formdata
25 messages · Page 1 of 1 (latest)
This is what you’re looking for: https://muffinman.io/blog/uploading-files-using-fetch-multipart-form-data/
||You can always type the same in google, you’ll get an answer 100%||
I tried some stuff and did not get it to work so I asked. Might come back.
Alright sure, but with such easy queries at least try lol. Mdn is a great place to start
Alright so got it to work.
What if I want to send more files at once though. 🤔
should be possible somehow
apparently I need to make it json somehow or something? I do not really understand this.
https://discord.com/developers/docs/reference#uploading-files
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
oh, then I guess
formData.append("files", file1);
formData.append("files", file2);
You need to encode them into a Blob. And I believe filesystem based blobs are not yet supported, tho I can't find an issue.
Not aware of any modern FormData library that accepts strings either
filesystem based blobs are not supported, but you can read the files into memory
that's only an issue if the files are huge
Where's the issue for filesystem based Blobs?
For my use case it will just be long strings converted to Blobs so I should be fine with that.
if the server is expecting files, they might need a filename and a mime type
but if you're building the blobs yourself, ok
File requires a name and has optional mime type
well, if you don't specify the mime type it gets set to the empty string
because multipart/form-data file fields must have a mime type header
but anyway
got it to work. Thanks for the help 👍