cancel
Showing results for 
Search instead for 
Did you mean: 

How to send pdf file in binary format to ECM

helloanikolkata
Explorer
0 Kudos
367

I am reading a PDF file from Azure Blob/SFTP and need to pass that to ECM. All text files are going properly but for PDF file it is storing in ECM successfully but while downloading, a blank pdf is showing. After reading the pdf from source, when I am checking that in CPI, is showing in a symbolic pattern. While placing this same to al11, I am getting the proper PDF but while passing this to ECM, it is showing blank pdf.

helloanikolkata_0-1723183523336.png

To make this working I am passing content type as "application/pdf" along with "multipart/form-data; boundary=CPI" as required for ECM. Do I need to pass any specific matadata in fileProperty, so that pdf will be stored properly? 

 

narasimha_yr
Explorer
0 Kudos

Hi,

Were you able to resolve this issue? I am also facing same issue handling PDF. Word and Text documents works fine, but PDFs are sent as blank pages to target system.

If your issue is resolved, can you please share the fix?

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

ShaikAzmathulla
Active Participant
0 Kudos

Hi ,

To make this working I am passing content type as "application/pdf" along with "multipart/form-data; boundary=CPI" as required for ECM. Do I need to pass any specific metadata in file Property, so that pdf will be stored properly?

My comments : 

Yes, ensure you pass the following metadata along with the file:

Content-Type: application/pdf
Content-Disposition: attachment; filename="filename.pdf"

Sample usage : 

def fileContent = new File("/path/to/your/file.pdf").text
def fileName = "file.pdf"
transformFileToECM(fileContent, fileName)

Regards ,

Azmath.

helloanikolkata
Explorer
0 Kudos

Hello Azmath,

Now I am sending as below..

--CPI
Content-Type: application/pdf
Content-Disposition: attachment; filename="${property.ExtractedfileName}"

${header.file}
--CPI
Content-Disposition: form-data; name="fileProperties"

${header.fileProperties}
--CPI--

but getting following error:

{
"traceId": "Id-777575757775757757575577",
"error": {
"code": 400,
"message": "File is empty. Please provide file to be uploaded.",
"target": "https://abcdefgh.com/enterprise-documents-api/api/v1/repositories/ecm-PropertyServices/documents"
}
}

Previously while file was going but showing blank pdf:

--CPI
Content-Disposition: form-data; name="file"; filename="${property.ExtractedfileName}"

${header.file}
--CPI
Content-Disposition: form-data; name="fileProperties"

${header.fileProperties}
--CPI--

chanumanthu
Discoverer
0 Kudos

Hi,

You may try using "InputStream" to read the content of the file using groovy script. Content from below code can be used in your POST call to ECM.

For ex:

def body = message.getBody(InputStream);

def content = body.getBytes();

Regards,

Chaitaanya Hanumanthu.