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
How to change the filename in http_mfd_encoder_addstmf
-
- Posts: 9
- Joined: Tue May 10, 2022 4:46 pm
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: How to change the filename in http_mfd_encoder_addstmf
Currently there isn't an option in HTTPAPI to remove the path, but you could do it with:
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.
- Use the IFS chdir() procedure to switch to the directory containing the attachment.
- only use the filename (not the entire pathname) when calling http_mfd_encoder_addstmf
Code: Select all
/copy IFSIO_H
.
.
chdir('/home/usr/pdf');
http_mfd_encoder_addstmf(enc: 'file': 'pdf_filename.pdf': 'application/pdf');
-
- Posts: 9
- Joined: Tue May 10, 2022 4:46 pm
Re: How to change the filename in http_mfd_encoder_addstmf
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.
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.