UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

68 lines 3.19 kB
import { UploaderState, UploadItem } from '@/utils/hooks/useUploadFileEntity/useUploadFiles'; import { PrepareFileEntityUploadArgs } from './usePrepareFileEntityUpload'; export type PromptInfo = { type: 'CONFIRM_NEW_VERSION'; fileName: string; existingEntityId: string; }; export type Prompt = { info: PromptInfo; onConfirmAll: () => void; onConfirm: () => void; onSkip: () => void; onCancelAll: () => void; }; export type EntityUploaderState = UploaderState | 'LOADING' | 'PROMPT_USER' | 'ERROR'; export type InitiateUploadArgs = PrepareFileEntityUploadArgs; export type UseUploadFileEntitiesReturn = { /** * The current state of the uploader */ state: EntityUploaderState; errorMessage?: string; /** * True if the uploader is doing work to prepare the upload (e.g. creating folders, checking for existing files), but the upload has not started. */ isPrecheckingUpload: boolean; /** * Prompts that require user input before the upload can proceed. Typically, these are prompts to confirm uploading a new version * of an existing FileEntity. * * If prompts are present, `state` will always be 'PROMPT_USER'. */ activePrompts: Prompt[]; /** * Arguments used to initialize an upload operation. In addition to providing a file, the caller must also provide one of * the following: * - rootContainerId: The ID of the parent Project or Folder to upload files to. If the File objects include a webkitRelativePath, * then the Files will be uploaded into created sub-folders to match the relative path. Any files that match on path and file name * will trigger a prompt to confirm updating a new version in the `activePrompts` field, which must be resolved before the upload can proceed. * - existingEntityId: The ID of the FileEntity for which a new version should be uploaded. No prompts will be triggered by this option. */ initiateUpload: (args: InitiateUploadArgs) => void; /** * The total number of files that are actively being uploaded (PREPARING, UPLOADING, or PAUSED) */ activeUploadCount: number; /** * A list of each file being uploaded, along with its progress, status, and callbacks that can be used to pause, resume, or cancel the upload. */ uploadProgress: UploadItem[]; /** True when files can be uploaded. */ isUploadReady: boolean; }; /** * Hook to start and track the progress of files uploads in Synapse, creating/updating a FileEntity for each uploaded file. * * To start an upload, see `initiateUpload` returned by this hook. */ export declare function useUploadFileEntities( /** The ID of the parent entity to upload files to, or the FileEntity for which a new version should be uploaded */ containerOrEntityId: string, /** Optional accessKey for a direct S3 upload */ accessKey?: string, /** Optional secretKey for a direct S3 upload */ secretKey?: string, /** Invoked if chosen files will exceed storage limits based on a client-side check. */ onStorageLimitExceeded?: () => void): UseUploadFileEntitiesReturn; //# sourceMappingURL=useUploadFileEntities.d.ts.map