Uploading PDF via API succeeds, but file cannot be previewed
Hi,
I'm trying to upload a PDF file to Box from NetSuite - I've constructed the multipart request body (see sample below), and the upload completes, but I cannot preview the file in Box and the file is corrupt when I download it and try to open it locally.
The contents of the file are encoded as a base64 string - I am passing the "content-transfer-encoding: base64" header, but this doesn't seem to be being understood by Box.
I've also tried to send the contents of the file unencoded, which allows a preview of the file, but the pages are blank. I'm thinking this is an encoding issue - what should be the correct encoding? I'm using UTF-8 at present - should this be ASCII?
Any assistance would be appreciated - thanks in advance.
--6070a6fd-0a49-4cc8-b822-5b80342b0074
content-disposition: form-data; name="attributes"
{"name":"testpdffile.pdf","parent":{"id":"0"},"content_created_at":"2021-02-04T10:53:43-08:00","content_modified_at":"2021-02-04T10:53:43-08:00"}
--6070a6fd-0a49-4cc8-b822-5b80342b0074
content-disposition: form-data; name="file"; filename="testpdffile.pdf"
content-type: application/pdf;charset=UTF-8
content-transfer-encoding: base64
JVBERi0xLjUKJeLjz9MKMjYgMCBvYmoKPDwvRmlsdGVyL0ZsYXRlRGVjb2RlL0xlbmd0aCAzNzMzPj5zdHJlYW0KeJzNWltv3DYWfp9fwbcmQKJKpK5b9CFJ0wV2t0m78e4...<data truncated for size>
--6070a6fd-0a49-4cc8-b822-5b80342b0074--
Post is closed for comments.
Comments
1 comment