#StackBounty: #node.js #amazon-s3 #aws-sdk #aws-sdk-nodejs #wasabi-hot-cloud-storage Image corrupted from s3

Bounty: 50

This is my upload code (node)

// generate a uuid string
            const uuid = uuidv4(); // type string

            // upload to wasabi

            fs.readFile(file.tempFilePath, "utf8", (err, data) => {
                if (err) {
                    throw (err);
                }
                // upload the object
                s3.upload(
                    {
                        Body: data,
                        Key: uuid + "-" + file.name,
                        Bucket: "files",
                        Metadata: { 'ext': ".png" },
                        // ContentLength: file.size
                    }, (err, data) => {
                        if (err) {
                            console.log(err);
                            throw (err);
                        }
                        console.log(data); 
                });
            });

The object actually does get to the bucket. It has more than 0 bytes. It is about half as small the source image but I’m just assuming someone is compressing it (wasabi or something).
I am using express-fileupload and my config for it is:


app.use(fileUpload({

    createParentPath: true,

    limits: {
        fileSize: 2 * 1024 * 1024 * 1024 //2MB max file(s) size
    },

    useTempFiles: true,

    tempFileDir: "/tmp/",

}));

Eventually I download this directly from the wasabi web client, and try to open it in an image viewer and they all say there is an error in the file or that they don’t support the file type (which is .png, so it is supported).
The image is only ~150kb .
Essentially the file gets there but its corrupted.


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.