Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

onUploadFinish error throw not being returned to client #380

Open
@bodhi-maligator

Description

Hi,

Not sure if I'm missing something. I tried a simple server:

`'use strict'

import {Server} from '@tus/server';
import {FileStore} from '@tus/file-store';

const host = '127.0.0.1'
const port = 1080
const server = new Server({
path: '/uploads',
datastore: new FileStore({directory: './uploads'}),
async onUploadFinish(req, res, upload) {
throw {body: 'no', status_code: 500};
return res;
}
})

server.listen({host, port})`

And when I try with a simple tus client:

`'use strict'

import * as fs from 'node:fs';
import * as tus from 'tus-js-client';

const path = './example.doc';
const file = fs.createReadStream(path);

const options = {
endpoint: 'http://127.0.0.1:1080/uploads/',
metadata: {
filename: 'example.doc',
filetype: 'application/msword',
description: 'scooby doobie doo'
},
onError (error) {
console.error('An error occurred:')
console.error(error)
process.exitCode = 1
},
onProgress (bytesUploaded, bytesTotal) {
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, ${percentage}%)
},
onSuccess () {
console.log('Upload finished:', upload.url)
},
};

const upload = new tus.Upload(file, options);
upload.start();`

The upload completes without error.

node ./tus-client.js
0 3690496 0.00%
65536 3690496 1.78%
3690496 3690496 100.00%
Upload finished: http://127.0.0.1:1080/uploads/b21c2577eee60411d30b9edc01d7b4ff

Any help would be appreciated!

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /