Hey there,
On February 19 I created a tiny project that would let me upload a single *.xls
file and convert it to a different format, then download it in the new format.
The project is pretty trivial and is only made of one static index.html
file and a single convert.js
function:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Convert</title>
</head>
<body>
<form
action="/.netlify/functions/convert"
method="POST"
enctype="multipart/form-data"
>
<input type="file" accept="application/vnd.ms-excel" />
<input type="submit">Submit</input>
</form>
</body>
</html>
exports.handler = async function (event, _context) {
const content = Buffer.from(event.body, "base64").toString("utf8");
const qif = convertToQIF(content);
return {
statusCode: 200,
headers: {
"Content-Type": "application/qif; charset=utf-8",
"Content-Disposition": 'attachment; filename="example.qif"',
},
body: qif,
};
};
function convertToQIF() {
// Details of this function are irrelevant for the purposes of this support request
return "It works!";
}
I am 99.9% confident that on February 19 convert
function was successfully receiving the full file content as a base64 encoded string. I was then able to decode it and parse/convert accordingly.
However, Today, on March 4, event.body
contains only the form boundary (e.g., ------WebKitFormBoundaryJdK3uPMIGB1mA2wm--
) and nothing else.
Also, note that the file uploaded is about 20KB in size (which I suppose shouldn’t be an issue) for Netlify functions.
I followed this guide with the exception of using the busboy
library because for the purposes of this tiny project, there wasn’t need for the additional complexity. However, I’d like to note that, after having noticed this new buggy behavior, I did try busboy
code snippet provided in the guide. As excepted, however, it didn’t change anything, as event.body
does not contain all the file contents in the first place.
So, I am very tempted to believe that between February 19 and March 4, 2020, something must have changed on Netlify to break file uploads.
Any ideas?