36
Views
10
Comments
To check if the uploaded binary data is null or not
Question
Application Type
Service
Service Studio Version
11.54.66 (Build 63364)
Platform Version
11.29.0 (Build 43552)

I have one expose post rest api which has a single input as binary data datatype which is accepted in body. And the uploaded binary file will always be JSON.

 

Now I want to check if the file I'm accepting should not be null or empty. So, I'm using two binary data actions 

  1. BinaryDataSize -  to check if the file size is 0 then it must be empty (But in this case I'm getting 214 bytes as default value even though I can see file value in file properties its showing 0 bytes).
  2. BinaryDataToText -  to check if the file is having empty contents but in this case it includes some text. For eg - "----------------------------280688845602140341089042\r\nContent-Disposition: form-data; name=\"File\"; filename=\"Empty.json\"\r\nContent-Type: application/json\r\n\r\n\r\n----------------------------280688845602140341089042--\r\n"

Just to let you know - as its service module I can't use js or client actions.

How can I do file validation - file size should be under 30 MB and the file should not be null or empty.

2023-05-23 04-55-55
Wasimkhan Syed Abuthahir

Hi,

May I know what are the expected binary values?


Regards,
Wasimkhan S

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

Hi @Wasim Khan,

Expected binary values is JSON data. 

For eg - 

{

"name": "FarmTest",            

"countrycode": "us",            

"type": "user"

}

2023-05-23 04-55-55
Wasimkhan Syed Abuthahir

You can receive JSON data as an input "Text". or can you send the sample binary data you are passing.


Regards,

Wasimkhan S

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

I have to recieve it as binary data only. Attaching dummy test file.

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

I have to recieve it as binary data only. Can't attach json file.

JSON content - 

{

  "type": "FeatureCollection",

  "features": [

    {

      "type": "Feature",

      "properties": {

        "Name": "FarmTest"

      },

      "geometry": {

        "coordinates": [

          [

            [

              29.1832273802396,

              9.900000362975291

            ],

            [

              29.1832273802396,

              9.892567362336791

            ],

            [

              29.191100706171625,

              9.892567362336791

            ],

            [

              29.191100706171625,

              9.900000362975291

            ],

            [

              29.1832273802396,

              9.900000362975291

            ]

          ]

        ],

        "type": "Polygon"

      },

      "id": 0

    }

  ]

}

2025-01-15 08-35-04
Vignesh Sekar

Hi Bhanu,

is it possible to share your test file?


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

Hi @vignesh S,

Can't attach JSON file.


JSON content - 

{

  "type": "FeatureCollection",

  "features": [

    {

      "type": "Feature",

      "properties": {

        "Name": "FarmTest"

      },

      "geometry": {

        "coordinates": [

          [

            [

              29.1832273802396,

              9.900000362975291

            ],

            [

              29.1832273802396,

              9.892567362336791

            ],

            [

              29.191100706171625,

              9.892567362336791

            ],

            [

              29.191100706171625,

              9.900000362975291

            ],

            [

              29.1832273802396,

              9.900000362975291

            ]

          ]

        ],

        "type": "Polygon"

      },

      "id": 0

    }

  ]

}

2021-10-09 07-57-44
Stefan Weber
 
MVP

Hi, according to the example you are providing your do not get a binary data in the body, but a multipart form request. You have to deal with the multipart first and you can use this component by @Kilian Hekhuis to parse the multipart body https://www.outsystems.com/forge/component-overview/4026/multipart-form-data-o11.

Stefan



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

Hi @Stefan Weber,

Thanks for your reply I'll check the links you provided.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Tbh parsing a received multipart/form-data wasn't written by me 😄

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