pushduck
Version:
The fastest way to add file uploads to any web application. Enterprise security, edge-ready. Works with 16+ frameworks and 5+ storage providers. No heavy AWS SDK required.
1 lines • 1.2 kB
JavaScript
"use client";import{formatETA as e,formatUploadSpeed as t,useUploadRoute as n}from"./use-upload-route-B5SY3QR0.mjs";import{useCallback as r}from"react";function i(e,t,i){let a={endpoint:i?.endpoint||t.endpoint,onSuccess:i?.onSuccess||t.defaultOptions?.onSuccess,onError:i?.onError||t.defaultOptions?.onError,onProgress:i?.onProgress||t.defaultOptions?.onProgress},o=n(e,a),s=r(async(n,r)=>i?.disabled||t.defaultOptions?.disabled?(console.warn(`Upload disabled for route: ${e}`),[]):(await o.uploadFiles(n),o.files.map(e=>({...e,metadata:r}))),[o.uploadFiles,o.files,i?.disabled,t.defaultOptions?.disabled,e]);return{files:o.files,uploadFiles:s,reset:o.reset,isUploading:o.isUploading,errors:o.errors,routeName:e,progress:o.progress,uploadSpeed:o.uploadSpeed,eta:o.eta}}function a(e){return new Proxy({},{get(t,n){if(typeof n!=`string`)throw Error(`Invalid route access: Routes must be strings, got ${typeof n}`);return t=>i(n,e,t)},has(e,t){return typeof t==`string`},ownKeys(){return[]},getOwnPropertyDescriptor(e,t){if(typeof t==`string`)return{enumerable:!0,configurable:!0,get:()=>this.get(e,t,e)}}})}export{a as createUploadClient,e as formatETA,t as formatUploadSpeed,n as useUploadRoute};