49
Views
5
Comments
Solved
To get filename and feature from uploaded binary data in REST API
Application Type
Service
Service Studio Version
11.54.66 (Build 63364)
Platform Version
11.29.0 (Build 43552)

I have an API which accepts only file as binary data datatype. Now I want to get the filename from it and the uploaded file will contain some JSON from which I need to read some feature how can I achieve that.


JSON Example -

{    "type": "FeatureCollection",    "features": [{            "type": "Feature",            "properties": {                "UniqueID": "AMGAAS",                "CountryCode": "LAM",                "latitude": "-0.3368",                "longitude": "35.2528"            },            "geometry": {                "coordinates": [[[1.081835, 6.352904], [1.102755, 6.36187], [1.092295, 6.385032], [1.074364, 6.385032], [1.081835, 6.352904]]],                "type": "Polygon"            }        }    ]}


I need to read country code from the above binary data that will uploaded through API.


Note - It is a service application. The API media type: 'multipart/form-data'.



2024-03-23 18-16-49
Bryan Villalobos
Solution

Hi @Bhanu Pratap Singh ,

If I understand your issue correctly, you basically have a binarydata that actually contains json text.

In this case, you first need to convert the binarydata into text using BinaryDataToText (BinaryData API).
Then convert the text data (json) into a structure that matches the json content. (You can create the structure using the format you have using 'Add Structure From Json').


Then you should be able to get what fields you need easily using the structure.

2024-10-09 04-44-30
Bhanu Pratap

Hi @Bryan Villalobos,

Thanks for your input.

I tried it but what if we are receiving file that may vary in terms of features. In that case can I define only those parameters in structure that I need.

2023-12-16 19-57-03
Sanjay Kushwah

Hi @Bhanu Pratap Singh,

I think you can convert above file into outsystems record and then you can access any value from the record using this component.

ConvertFileToRecord - Overview (O11) | OutSystems 

Hope this will help you


Kind regards,

Sanjay Kushwah

2024-10-09 04-44-30
Bhanu Pratap

Hi @Sanjay Kushwah,

Thanks for your input.

But what if we are receiving file that may vary in terms of features. In that case I can't make a entity like that.

2023-12-16 19-57-03
Sanjay Kushwah

You need to somehow recognize which kind features file you are getting.

and can make Multiple structures to map with output. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.