# Send multiple files as multipart/form data using web request

**URL:** <https://community.appfarm.io/t/send-multiple-files-as-multipart-form-data-using-web-request/819>\
**Category:** Ask the community\
**Tags:** web-request\
**Created:** [November 8, 2023, 10:31am UTC](https://community.appfarm.io/t/send-multiple-files-as-multipart-form-data-using-web-request/819 "2023-11-08T10:31:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kjellamund](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@Kjellamund](https://community.appfarm.io/u/Kjellamund)\
**Post date:** [November 8, 2023, 10:31am UTC](https://community.appfarm.io/t/send-multiple-files-as-multipart-form-data-using-web-request/819/1 "2023-11-08T10:31:31Z")

</div>

Hi!

I would like to send POST requests to another system with attachments. 3rd party system expects that payload will be multipart/form data with an array of files in the body.  
Number of files to send can vary, for one case it will be 1 file, for another it will be 3 files.

Question is - is it possible to send multiple files in one request? I.e. i have a file object class with cardinality many, is it possible to send all objects from it in one request?

---

<div class="post-metadata">

**Author:** ![ErikAKSkallevold](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/erikakskallevold/32/1378_2.png) [@ErikAKSkallevold](https://community.appfarm.io/u/ErikAKSkallevold)\
**Post date:** [November 8, 2023, 1:41pm UTC](https://community.appfarm.io/t/send-multiple-files-as-multipart-form-data-using-web-request/819/2 "2023-11-08T13:41:38Z")

</div>

Hi,

For clients, the File Object Class has a property called `fileData` that might be useful for you. `fileData` contains the binary data of the file in a Blob which you can use to POST to your 3rd party system. You can access this field in the function editor with `fileObjectClassName.__file` (2 underscores). Also note that you will have to slice the `Blob` from `0` to `file.length` to have Appfarm return it as an blob.

You can then use JS code in a web requests body to iterate over all objects in your `File Object Class (Many)` and add them to an array. Then you can send the whole array as an JSON object to your 3rd party system.

There are two prerequistes however:

1. Files over 1GB might hang or crash your web browser and are not recommended.

2. The web request must be sent from a client. Blobs are stored in your browser session, not on Appfarms servers, so you must check the `send from client` box on your web request. This also means that you will not be able to send the data from a service, since that is run server-side.

Depending on how many files you attempt to send, and how large they are, the web request might time out. If you experience this, you could increase the timeout limit.

By doing this I was able to create an array of blobs in my web request body. I have also attached some pictures.

 ![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/ee8ba891de35d47e64ef550eb106c90218121b6c.png)  
 ![bilde](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/7cbdda0ee181c6deea1fac17013942ff258dea32.png)

---

<div class="post-metadata">

**Author:** ![Kjellamund](https://avatars.discourse-cdn.com/v4/letter/k/ba9def/32.png) [@Kjellamund](https://community.appfarm.io/u/Kjellamund)\
**Post date:** [November 8, 2023, 2:19pm UTC](https://community.appfarm.io/t/send-multiple-files-as-multipart-form-data-using-web-request/819/3 "2023-11-08T14:19:07Z")

</div>

Thank you for the thorough instructions!
