UNPKG

upup-react-file-uploader

Version:
131 lines (119 loc) 3.9 kB
import { S3ClientConfig } from '@aws-sdk/client-s3'; declare enum UpupProvider { AWS = "aws", Azure = "azure", BackBlaze = "backblaze", DigitalOcean = "digitalocean" } type PresignedUrlResponse = { key: string; publicUrl: string; uploadUrl: string; expiresIn: number; }; /** * Response from tokenEndpoint for multipart:init action */ type MultipartInitResponse = { key: string; uploadId: string; partSize: number; expiresIn: number; }; /** * Response from tokenEndpoint for multipart:signPart action */ type MultipartSignPartResponse = { uploadUrl: string; expiresIn: number; }; /** * A single uploaded part reference */ type MultipartPart = { partNumber: number; eTag: string; }; /** * Response from tokenEndpoint for multipart:listParts action */ type MultipartListPartsResponse = { parts: MultipartPart[]; }; /** * Response from tokenEndpoint for multipart:complete action */ type MultipartCompleteResponse = { key: string; publicUrl: string; }; /** * Response from tokenEndpoint for multipart:abort action */ type MultipartAbortResponse = { ok: true; }; interface FileParams { name: string; type: string; size: number; accept?: string; maxFileSize?: number; multiple?: boolean; } interface UrlParams { fileParams: FileParams; expiresIn?: number; } type S3PresignedUrlParams = UrlParams & { bucketName: string; s3ClientConfig: S3ClientConfig; origin: string; provider: UpupProvider; enableAutoCorsConfig?: boolean; }; type AzureSasUrlParams = UrlParams & { containerName: string; credentials: AzureCredentials; }; type AzureCredentials = { tenantId: string; clientId: string; clientSecret: string; storageAccount: string; }; type S3MultipartParams = { bucketName: string; s3ClientConfig: S3ClientConfig; origin: string; provider: UpupProvider; enableAutoCorsConfig?: boolean; expiresIn?: number; }; declare function s3AbortMultipartUpload({ bucketName: Bucket, s3ClientConfig, key, uploadId, }: S3MultipartParams & { key: string; uploadId: string; }): Promise<MultipartAbortResponse>; declare function s3CompleteMultipartUpload({ bucketName: Bucket, s3ClientConfig, key, uploadId, parts, }: S3MultipartParams & { key: string; uploadId: string; parts: MultipartPart[]; }): Promise<MultipartCompleteResponse>; declare function s3GeneratePresignedPartUrl({ bucketName: Bucket, s3ClientConfig, expiresIn, key, uploadId, partNumber, contentLength, }: S3MultipartParams & { key: string; uploadId: string; partNumber: number; contentLength: number; }): Promise<MultipartSignPartResponse>; declare function s3GeneratePresignedUrl({ fileParams, bucketName: Bucket, s3ClientConfig, expiresIn, origin, provider, enableAutoCorsConfig, }: S3PresignedUrlParams): Promise<PresignedUrlResponse>; declare function s3GenerateSignedUrl(s3ClientConfig: S3ClientConfig, Key: string, Bucket: string, expiresIn?: number): Promise<string>; declare function s3InitiateMultipartUpload({ fileParams, bucketName: Bucket, s3ClientConfig, expiresIn, origin, provider, enableAutoCorsConfig, chunkSizeBytes, }: S3MultipartParams & { fileParams: FileParams; chunkSizeBytes?: number; }): Promise<MultipartInitResponse>; declare function s3ListMultipartParts({ bucketName: Bucket, s3ClientConfig, key, uploadId, }: S3MultipartParams & { key: string; uploadId: string; }): Promise<MultipartListPartsResponse>; declare function azureGenerateSasUrl({ fileParams, containerName, credentials, expiresIn, }: AzureSasUrlParams): Promise<PresignedUrlResponse>; export { UpupProvider, azureGenerateSasUrl, s3AbortMultipartUpload, s3CompleteMultipartUpload, s3GeneratePresignedPartUrl, s3GeneratePresignedUrl, s3GenerateSignedUrl, s3InitiateMultipartUpload, s3ListMultipartParts };