useTusResumeStartListener
Packageβ
Installationβ
- npm
- Yarn
- pnpm
npm install @rpldy/tus-uploady
yarn add @rpldy/tus-uploady
pnpm add @rpldy/tus-uploady
Detailsβ
type useTusResumeStartListener = (cb: (data: TusResumeStartEventData) => TusResumeStartEventResponse) => void;
note
Event Hook - RESUME_START
info
This event is cancellable
Called before the (HEAD) request is issued on behalf of a potentially resumeable upload.
Receives an object with:
- url: the URL the resume (HEAD) request will be sent to
- item: the BatchItem being sent
- resumeHeaders: an optional object that was passed to the TusUploady props
May return false
to cancel the resume, nothing, or an object
with:
Cancelling the request (return false
) will not abort the entire upload, but rather cancel the fetching of resume info.
url
property to overwrite the URL the request will be sent to.- And/Or a
resumeHeaders
object that will be merged with the optional object passed as a prop to TusUploady.
import React from "react";
import { useTusResumeStartListener } from "@rpldy/tus-uploady";
const MyComponent = () => {
useTusResumeStartListener(({ url, item, resumeHeaders }) => {
return cancelResume ? false : {
resumeHeaders: {
"x-another-header": "foo",
"x-test-override": "def"
}
}
});
//...
};