Checksums in tus-node-server

Started by moonraker5956 replies1,333 views
moonraker595Original post
#1

Hi,

I’ve noticed here that the checksum extension is not supported for the tus-node-server. Is there a reason for that?

Is there any other recommended way I might be able to get (or calculate) the checksum in the onUploadCreate callback?

For reference, I’m using the uppy dashboard with tus connected to the S3Store plugin.

Thanks

moonraker595
#2

Anyone using checksums in Node.js?

MerlijnTransloadit team
#3

Hi, this has not been implemented yet. You might be able to do this yourself if you are not setting a chunkSize on the client (so everything is done over one request), use the Creation with Upload extension, and read the entire body in onUploadCreate and try to verify it.

However I haven’t looked closely enough into the Checksum extension to know the edge cases with this approach rather than building it into the server itself.

moonraker595
#4

Hi,

Thanks alot for your reply. I’m not sure about the phasing here and in the docs. Do I need to do anything to be able to use Creation with Upload extension, or does the tus-node-server implement it by default? I can’t see any example of how to use it.

For example, this is my init function:

const tusDatafileServer = new Server({
    path: '/upload',
    datastore: datafileS3Store,
    // callback provided by tus, gets called for each upload
    async onUploadCreate(req, res, upload) {
        return res;
    },
})

I’m not chunking anything and I’m not seeing any body in req, unless its called something else? req.headers seems to read fine.

Thanks

MerlijnTransloadit teamReplying to #4
#5

You can set it on the client and it will work in the server:

Then you should always have a body at the time of onUploadCreate. Maybe @marius knows if there are caveats to attempting this in a hook.

moonraker595
#6

Thanks for this. I’m setting the flag in Uppy:

uppy.use(Tus, {
    endpoint: 'http://0.0.0.0:8181/upload/',
    uploadDataDuringCreation: true,
});

But still can’t see a body in req.

marius
#7

Setting uploadDataDuringCreation: true should be enough to cause tus-js-client to put the upload data in the POST request (instead of the PATCH request).