2

I have to send an octet stream fetched from S3 through an api. I need to change the name of the file received. Does octet stream contain the name of the file ? if yes ,How can I extract the file name from the octet stream ? if no, is there any other way to send an octet stream and attach a file name to it ?

The alternative approach is that I change the name of file before saving it to S3. but I was wondering if it is possible to manipulate the octet stream.

import dw::module::Multipart
output multipart/form-data 
---
{
  parts: {
    part1: Multipart::field({name:"data",value: vars.xmlData, mime:"application/xml"}),
    part2: Multipart::field({name:"file",value: vars.docAsBytes,mime:"application/octet-stream"})
  }
}

EDIT:

This worked for me

output multipart/form-data
---
{
                parts : {
                    file : {
                            headers : {
                                "Content-Disposition" : {
                                "name": "file",
                                "filename": "abcdef.jpeg"     
                            },
                            "Content-Type" : "image/jpeg",
                        },
                        content : vars.base64string
                    }
       
                }
            
HMT
  • 2,093
  • 1
  • 19
  • 51

1 Answers1

2

Long story short: An octet stream doesn't contain any filename, unless it's some structure which is just encoded as octet stream - but in most of the cases, it's just the binary data of the file.

For sending filenames in multipart/form-data forms, the Content-Disposition header is considered standard.

maio290
  • 6,440
  • 1
  • 21
  • 38