postcode icon indicating copy to clipboard operation
postcode copied to clipboard

Binary files do not upload correctly

Open hypesystem opened this issue 3 years ago • 0 comments

I was using the library for some simple testing, and got a very obscure issue with binary files not uploading correctly. It looks like they are sent wrongly encoded on the request side.

A simple test case in Node.js:

const fs = require("fs");
const express = require("express");

const app = express();
app.use("/", (req, res) => {
  const writeStream = fs.createWriteStream(req.query.filename || "output.txt");
  req.pipe(writeStream);
  res.send();
});
app.listen(2342);

This creates a HTTP app on port 2342 that writes the body of any request to the filename given as a query parameter, e.g. http://localhost:2342/?filename=uploaded.zip means saving the file to uploaded.zip in the app dir.

If I upload a .zip file like the attached test.zip as a "binary" file via Postcode (latest version, installed today), and try to open the resulting uploaded.zip, it will be invalid.

The same flow works as intended in Postman.

Attachments:

test.zip

hypesystem avatar Dec 16 '22 12:12 hypesystem