Skip to main content

useRequestPreSend

Package​

@rpldy/uploady

Installation​

npm install @rpldy/uploady

Details​

type useRequestPreSend = (cb: (data: PreSendData) =>
PreSendResponse | boolean | Promise<PreSendResponse | boolean> | Promise<boolean>) => void;
note

Event Hook - BATCH-START

Called before a group of items is going to be uploaded Group will contain a single item unless "grouped" option is set to true (default = false).

Handler receives the item(s) in the group and the upload options that were used. The handler can change data inside the items and in the options by returning different data than received. See simple example below or this more detailed guide.

info

This event is cancellable

    import { useRequestPreSend } from "@rpldy/uploady";

const MyComponent = () => {
useRequestPreSend(({ items, options }) => {
let method = options.method;

if (options.destination.url.startsWith("https://put-server")) {
method = "PUT";
}

return {
options: { method } //will be merged with the rest of the options
};
});

//...
};