useTusPartStartListener
Packageβ
Installationβ
- npm
- Yarn
- pnpm
npm install @rpldy/tus-uploady
yarn add @rpldy/tus-uploady
pnpm add @rpldy/tus-uploady
Detailsβ
type useTusPartStartListener: (cb: (data: TusPartStartEventData) => TusPartStartEventResponse) => void;
note
Event Hook - PART_START
Called before a (PATCH) request is issued to upload a chunk (part) of a file.
Receives an object with:
- url: the URL the PATCH request will be sent to
- item: the BatchItem being sent
- headers: the headers that will be sent with the request
- chunk: the chunk info (start, end, chunkSize)
May return nothing or an object with:
urlproperty to overwrite the URL the request will be sent toheadersobject that will be merged with the headers that will be sent with the request.
import React from "react";
import { useTusPartStartListener } from "@rpldy/tus-uploady";
const MyComponent = () => {
useTusPartStartListener(({ item, chunk, headers, url }) => {
const authHeaderVal = headers["Authorization"];
return {
headers: {
"Authorization": authHeaderVal + "-part-" + (chunk.index + 1),
}
};
});
//...
};