Page 1 of 1

How to change the filename in http_mfd_encoder_addstmf

Posted: Mon Sep 26, 2022 5:47 pm
by sgonchigar
Hello,

I am using http_mfd_encoder_addstmf to upload files, the content disposition filename shows the full IFS path. Wondering if there is a way to override that.

Example: Request header
Content-Disposition: form-data; name="file"; filename="/home/user/pdf/<pdf_filename>"
Content-Type: application/octet-stream

Thank you,
Sunil

Re: How to change the filename in http_mfd_encoder_addstmf

Posted: Tue Sep 27, 2022 2:07 am
by Scott Klement
Currently there isn't an option in HTTPAPI to remove the path, but you could do it with:
  1. Use the IFS chdir() procedure to switch to the directory containing the attachment.
  2. only use the filename (not the entire pathname) when calling http_mfd_encoder_addstmf
For example:

Code: Select all

/copy IFSIO_H
.
.
chdir('/home/usr/pdf');
http_mfd_encoder_addstmf(enc: 'file': 'pdf_filename.pdf': 'application/pdf');
Or, if you prefer an option could be added to HTTPAPI to strip off the path. Nobody has needed this yet (since the server typically ignores the path, anyway) but it could be added as an option if the above doesn't work well enough for you.

Re: How to change the filename in http_mfd_encoder_addstmf

Posted: Tue Sep 27, 2022 7:01 pm
by sgonchigar
Thank you Scott for the response. I tried the IFS chgdir(). It did not attach the file.
The REST service had a limitation on the file name length of 64 char and 10 char for the extension. I realized what my issue was after you mentioned that the path is ignored by the host system. I was appending 26 char timestamp to the file that I was working with to keep it unique for troubleshooting purpose. I removed the logic to append timestamp and now the length is less than 64 char and getting successful response. I am good with leaving http_mfd_encoder_addstmf as is.

Thank you again for the quick response.