Skip to main content

File is damaged after uploading into PDF.co via presigned url

File is damaged after uploading into PDF.co via presigned url

If the upload succeeds but the file opens as damaged, check what your application sent in the PUT request. Send the original file bytes directly to presignedUrl. Wrapping the file in FormData adds multipart headers and boundaries to the uploaded content.

If the upload fails with SignatureDoesNotMatch, check the Content-Type header. Its value must match the contenttype value used when generating the presigned URL.

Upload examples

In these Axios examples, file is the original file or a buffer containing its bytes. Use the presignedUrl returned by GET /v1/file/upload/get-presigned-url for the upload.

PDF example. If you requested the URL with contenttype=application/pdf, send the PDF with the same header value.

await axios.put(presignedUrl, file, {
  headers: { "Content-Type": "application/pdf" }
});

Binary upload example. If you requested the URL with contenttype=application/octet-stream, use that value for the upload. This also applies when the file is a PDF.

await axios.put(presignedUrl, file, {
  headers: { "Content-Type": "application/octet-stream" }
});

After the upload succeeds, use the returned url as the input for your next PDF.co request.

Did this answer your question?