0

I'm looking to send some files over HTTP from one server to another, and am wondering what the best MIME type and method to do so is. Currently I have a RESTful HTTP server and have an endpoint which may return one or more files, and am returning the contents as json with the text in the json body. This works well for text files, but for a binary format, I would have to base64 encode the contents which isn't an option.

I have looked into multipart/form-data, multipart/mixed, and application/zip, but don't have enough experience to weigh the pros and cons myself. I want this data to be send back in the HTTP response to a get request, which is why I'm slightly hesitant to use multipart/form-data as I've seen it used a lot for post requests to servers. Any thoughts?

3
  • Can you just do multiple HTTP requests? Commented Sep 4, 2024 at 20:03
  • The problem is that the exact file names are not known. The endpoint takes in a regex which collects files whos name match the regex on the server. Then these files are returned. It could be many http requests in order to retrieve all of the files, and therefore is not preferred @Evert Commented Sep 4, 2024 at 20:52
  • What if you return a list of URLs pointing to the files that match the regex from an initial endpoint, and then your client downloads each file separately. There's a lot of benefits to keeping things super simple. Commented Sep 4, 2024 at 20:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.