Customer Portal

Upload binary file with a data service

Comments 2

  • Avatar
    Ladislav Szabo
    • Official comment
    Comment actions Permalink

    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 component and set its URL to 'request:part:datafile' to access the parameter.
    6. Connect the FlatFileReader's output port to a FlatFileWriter 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' values for 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 CTL function.

    In such case, you need to:

    1. Create a dictionary 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 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.

  • Avatar
    Brandon Russell
    0
    Comment actions Permalink

    This worked so perfectly Ladislav, thank you very much.

Please sign in to leave a comment.