PageSourceSearch

https://react-uploady.netlify.app/assets/js/98d1dab8.e16e6ce3.js

js react-uploady.netlify.app collected 2026-10-03 11:20:28 UTC 10,055 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkreact_uploady_docs=self.webpackChunkreact_uploady_docs||[]).push([[2386],{56:(e,n,t)=>{t.d(n,{A:()=>l});t(6363);var a=t(3526);const r={tabItem:"tabItem_WQI_"};var s=t(7259);function l(e){let{children:n,hidden:t,className:l}=e;return(0,s.jsx)("div",{role:"tabpanel",className:(0,a.A)(r.tabItem,l),hidden:t,children:n})}},810:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>u,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>d});const a=JSON.parse('{"id":"api/hooks/useRequestPreSend","title":"useRequestPreSend","description":"Package","source":"@site/docs/api/hooks/useRequestPreSend.mdx","sourceDirName":"api/hooks","slug":"/api/hooks/useRequestPreSend","permalink":"/docs/api/hooks/useRequestPreSend","draft":false,"unlisted":false,"editUrl":"https://github.com/rpldy/react-uploady-docs/edit/master/docs/api/hooks/useRequestPreSend.mdx","tags":[{"inline":true,"label":"hook","permalink":"/docs/tags/hook"},{"inline":true,"label":"event","permalink":"/docs/tags/event"},{"inline":true,"label":"batchItem","permalink":"/docs/tags/batch-item"},{"inline":true,"label":"cancellable","permalink":"/docs/tags/cancellable"}],"version":"current","lastUpdatedAt":1644316370000,"frontMatter":{"id":"useRequestPreSend","title":"useRequestPreSend","pagination_label":"useRequestPreSend","sidebar_label":"\ud83e\ude9d useRequestPreSend","tags":["hook","event","batchItem","cancellable"]},"sidebar":"api","previous":{"title":"usePasteUpload","permalink":"/docs/api/hooks/usePasteUpload"},"next":{"title":"useRetry","permalink":"/docs/api/hooks/useRetry"}}');var r=t(7259),s=t(9058),l=t(4061),o=t(56);const i={id:"useRequestPreSend",title:"useRequestPreSend",pagination_label:"useRequestPreSend",sidebar_label:"\ud83e\ude9d useRequestPreSend",tags:["hook","event","batchItem","cancellable"]},u=void 0,c={},d=[{value:"Package",id:"package",level:2},{value:"Installation",id:"installation",level:2},{value:"Details",id:"details",level:2}];function p(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h2,{id:"package",children:"Package"}),"\n",(0,r.jsx)(n.p,{children:(0,r.jsx)(n.strong,{children:(0,r.jsx)(n.em,{children:(0,r.jsx)(n.a,{href:"../../../packages/rpldy-uploady",children:"@rpldy/uploady"})})})}),"\n",(0,r.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,r.jsxs)(l.A,{groupId:"npm2yarn",children:[(0,r.jsx)(o.A,{value:"npm",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"npm install @rpldy/uploady\n"})})}),(0,r.jsx)(o.A,{value:"yarn",label:"Yarn",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"yarn add @rpldy/uploady\n"})})}),(0,r.jsx)(o.A,{value:"pnpm",label:"pnpm",children:(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-bash",children:"pnpm add @rpldy/uploady\n"})})})]}),"\n",(0,r.jsx)(n.h2,{id:"details",children:"Details"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-typescript",children:"type useRequestPreSend = (cb: (data: PreSendData) =>\n    PreSendResponse | boolean | Promise<PreSendResponse | boolean> | Promise<boolean>) => void;\n"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["See: ",(0,r.jsx)(n.a,{href:"../../types#presendresponse",children:"PreSendResponse"})]}),"\n",(0,r.jsxs)(n.li,{children:["See: ",(0,r.jsx)(n.a,{href:"../../types#presenddata",children:"PreSendData"})]}),"\n"]}),"\n",(0,r.jsx)(n.admonition,{type:"note",children:(0,r.jsxs)(n.p,{children:["Event Hook - ",(0,r.jsx)(n.a,{href:"../../events#batchStart",children:"BATCH-START"})]})}),"\n",(0,r.jsx)(n.p,{children:'Called before a group of items is going to be uploaded\nGroup will contain a single item unless "grouped" option is set to true (default = false).'}),"\n",(0,r.jsxs)(n.p,{children:["Handler receives the item(s) in the group and the upload options that were used.\nThe handler can change data inside the items and in the options by returning different data than received.\nSee simple example below or this more detailed ",(0,r.jsx)(n.a,{href:"../../../guides/DynamicParameters",children:"guide"}),"."]}),"\n",(0,r.jsx)(n.admonition,{type:"info",children:(0,r.jsxs)(n.p,{children:["This event is ",(0,r.jsx)(n.em,{children:(0,r.jsx)(n.a,{href:"../../events#cancellable-events",children:"cancellable"})})]})}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-javascript",children:'    import { useRequestPreSend } from "@rpldy/uploady";\n\n    const MyComponent = () => {\n        useRequestPreSend(({ items, options }) =>
1 {\n            let method = options.method;\n\n            if (options.destination.url.startsWith("https://put-server")) {\n                method = "PUT";\n            }\n\n            return {\n                options: { method } //will be merged with the rest of the options\n            };\n        });\n\n        //...\n    };\n'})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(p,{...e})}):p(e)}},4061:(e,n,t)=>{t.d(n,{A:()=>S});var a=t(6363),r=t(3526),s=t(5269),l=t(6782),o=t(7596),i=t(6853),u=t(7667),c=t(3040),d=t(820);function p(e){return a.Children.toArray(e).filter((e=>"\n"!==e)).map((e=>{if(!e||(0,a.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs> child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)}))?.filter(Boolean)??[]}function h(e){const{values:n,children:t}=e;return(0,a.useMemo)((()=>{const e=n??function(e){return p(e).map((e=>{let{props:{value:n,label:t,attributes:a,default:r}}=e;return{value:n,label:t,attributes:a,default:r}}))}(t);return function(e){const n=(0,c.XI)(e,((e,n)=>e.value===n.value));if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map((e=>e.value)).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e}),[n,t])}function m(e){let{value:n,tabValues:t}=e;return t.some((e=>e.value===n))}function b(e){let{queryString:n=!1,groupId:t}=e;const r=(0,o.W6)(),s=function(e){let{queryString:n=!1,groupId:t}=e;if("string"==typeof n)return n;if(!1===n)return null;if(!0===n&&!t)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return t??null}({queryString:n,groupId:t});return[(0,u.aZ)(s),(0,a.useCallback)((e=>{if(!s)return;const n=new URLSearchParams(r.location.search);n.set(s,e),r.replace({...r.location,search:n.toString()})}),[s,r])]}function f(e){const{defaultValue:n,queryString:t=!1,groupId:r}=e,s=h(e),[l,o]=(0,a.useState)((()=>function(e){let{defaultValue:n,tabValues:t}=e;if(0===t.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(n){if(!m({value:n,tabValues:t}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${n}" but none of its children has the corresponding value. Available values are: ${t.map((e=>e.value)).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return n}const a=t.find((e=>e.default))??t[0];if(!a)throw new Error("Unexpected error: 0 tabValues");return a.value}({defaultValue:n,tabValues:s}))),[u,c]=b({queryString:t,groupId:r}),[p,f]=function(e){let{groupId:n}=e;const t=function(e){return e?`docusaurus.tab.${e}`:null}(n),[r,s]=(0,d.Dv)(t);return[r,(0,a.useCallback)((e=>{t&&s.set(e)}),[t,s])]}({groupId:r}),v=(()=>{const e=u??p;return m({value:e,tabValues:s})?e:null})();(0,i.A)((()=>{v&&o(v)}),[v]);return{selectedValue:l,selectValue:(0,a.useCallback)((e=>{if(!m({value:e,tabValues:s}))throw new Error(`Can't select invalid tab value=${e}`);o(e),c(e),f(e)}),[c,f,s]),tabValues:s}}var v=t(1751);const g={tabList:"tabList_hEov",tabItem:"tabItem_bQse"};var x=t(7259);function y(e){let{className:n,block:t,selectedValue:a,selectValue:s,tabValues:o}=e;const i=[],{blockElementScrollPositionUntilNextRender:u}=(0,l.a_)(),c=e=>{const n=e.currentTarget,t=i.indexOf(n),r=o[t].value;r!==a&&(u(n),s(r))},d=e=>{let n=null;switch(e.key){case"Enter":c(e);break;case"ArrowRight":{const t=i.indexOf(e.currentTarget)+1;n=i[t]??i[0];break}case"ArrowLeft":{const t=i.indexOf(e.currentTarget)-1;n=i[t]??i[i.length-1];break}}n?.focus()};return(0,x.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":t},n),children:o.map((e=>{let{value:n,label:t,attributes:s}=e;return(0,x.jsx)("li",{role:"tab",tabIndex:a===n?0:-1,"aria-selected":a===n,ref:e=>{i.push(e)},onKeyDown:d,onClick:c,...s,className:(0,r.A)("tabs__item",g.tabItem,s?.className,{"tabs__item--active":a===n}),children:t??n},n)}))})}function j(e){let{lazy:n,children:t,selectedValue:s}=e;
1const l=(Array.isArray(t)?t:[t]).filter(Boolean);if(n){const e=l.find((e=>e.props.value===s));return e?(0,a.cloneElement)(e,{className:(0,r.A)("margin-top--md",e.props.className)}):null}return(0,x.jsx)("div",{className:"margin-top--md",children:l.map(((e,n)=>(0,a.cloneElement)(e,{key:n,hidden:e.props.value!==s})))})}function k(e){const n=f(e);return(0,x.jsxs)("div",{className:(0,r.A)(s.G.tabs.container,"tabs-container",g.tabList),children:[(0,x.jsx)(y,{...n,...e}),(0,x.jsx)(j,{...n,...e})]})}function S(e){const n=(0,v.A)();return(0,x.jsx)(k,{...e,children:p(e.children)},String(n))}},9058:(e,n,t)=>{t.d(n,{R:()=>l,x:()=>o});var a=t(6363);const r={},s=a.createContext(r);function l(e){const n=a.useContext(s);return a.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),a.createElement(s.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.