# Upload binary file with a data service

**URL:** <https://forum.cloverdx.com/t/upload-binary-file-with-a-data-service/2164>\
**Category:** CloverDX Platform\
**Created:** [May 29, 2024, 10:00pm UTC](https://forum.cloverdx.com/t/upload-binary-file-with-a-data-service/2164 "2024-05-29T22:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Russell](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@Brandon\_Russell](https://forum.cloverdx.com/u/Brandon_Russell)\
**Post date:** [May 29, 2024, 10:00pm UTC](https://forum.cloverdx.com/t/upload-binary-file-with-a-data-service/2164/1 "2024-05-29T22:00:00Z")

</div>

I would like to use a data service to allow users to upload a zip file that is then processed by a graph. It looks like you can create form parameters that are binary. And running the data service, it allows you to pick a file to upload, I’m just not sure how to accept the file and then save it to disk someone in order to process by my graph.

---

<div class="post-metadata">

**Author:** ![Ladislav\_Szabo](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/ladislav_szabo/32/168_2.png) [@Ladislav\_Szabo](https://forum.cloverdx.com/u/Ladislav_Szabo)\
**Post date:** [May 30, 2024, 3:22pm UTC](https://forum.cloverdx.com/t/upload-binary-file-with-a-data-service/2164/2 "2024-05-30T15:22:56Z")

</div>

Hi Brandon,

You are on the right track with the binary form parameter for the file upload. Once you create the parameter, you can access it with ‘ **request:part:\<form\_parameter\_name\>** ’ in the Reader component’s URL and save it with a Writer component afterward. Here is the step-by-step guide:

1. Within your Data Service, switch to Endpoint Configuration.
2. Set the Data Services input format to binary.
3. Create a binary file form parameter (e.g., datafile).
4. Switch back to the Data Service REST Job (graph view).
5. Add the **[FlatFileReader](https://doc.cloverdx.com/latest/designer/flatfilereader.html)** component and set its URL to ‘ **request:part:datafile** ’ to access the parameter.
6. Connect the FlatFileReader’s output port to a **[FlatFileWriter](https://doc.cloverdx.com/latest/designer/flatfilewriter.html)** component.
7. To send the file over the edge, you want the metadata to contain a single byte field. Additionally, remove the ' **Record delimiter’** and ' **Default delimiter’** valuesfor the record and set the ‘ **EOF as delimiter** ’ property to **true.**
8. Lastly, set the FlatFileWriter’s URL to where you want to save the file (e.g., ${DATAIN\_DIR}/upload.zip)

If you want to save the file with its original name, use the **[getRequestPartFilename](https://doc.cloverdx.com/latest/designer/http-ctl2.html#id%5Fctl2%5Fgetrequestpartfilename)** CTL function.

In such case, you need to:

1. Create a [dictionary](https://doc.cloverdx.com/latest/designer/dictionary.html) entry that you’ll use to store the filename.
2. Acquire the filename in CTL with the **getRequestPartFilename** function and store it in the created dictionary. You can use the **[GetJobInput](https://doc.cloverdx.com/latest/designer/getjobinput.html)** component for this purpose.
3. Use the dictionary in the FlatFileWriter component’s URL - ‘dict:\<dictionary\_entry\_name\>:source’. Note that you must put components accessing the same dictionary into different phases. Therefore, please place the GetJobInput component into a lower phase than the FlatFileWriter component.

Kind regards.

---

<div class="post-metadata">

**Author:** ![Brandon\_Russell](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@Brandon\_Russell](https://forum.cloverdx.com/u/Brandon_Russell)\
**Post date:** [June 27, 2024, 5:44pm UTC](https://forum.cloverdx.com/t/upload-binary-file-with-a-data-service/2164/3 "2024-06-27T17:44:11Z")

</div>

This worked so perfectly Ladislav, thank you very much.
