Upload File
Upload File dùng để thực hiện upload các file lên shopify
Ví dụ
import { UploadFile } from '@xobuilder/ui';
const Demo: FC = () => {
return (
<UploadFile onUploadSuccess={files => {console.log(files)}} showToast={false}>
{({ pendingFiles }) => <>{JSON.stringify(pendingFiles)}</>}
<UploadFile.DropZone {...rest}>
<div className={styles.dropzone}>
<button className={styles.btnOpenLib} type="button" onClick={handleOpen}>
{i18n.t('general.select_images')}
</button>
<button className={styles.btnOpenExplore} type="button" onClick={handleOpen}>
{i18n.t('media.explore_free_images')}
</button>
</div>
</UploadFile.DropZone>
</UploadFile>
);
};
Props
UploadFileProps
Name | Type | Default | Description |
---|---|---|---|
showToast | string | - | Mặc định true. Hiện trạng thái upload |
onUploadSuccess | (files: FileEntity.NodeFile[]) => void | - | Trả về files khi upload xong 1 lượt (mỗi lượt 5 files) |
children | ReactNode | - | Nội dung hiển thị trong UploadFile |
onStatusUploading | (state: boolean) => void | - | Trả về trạng thái upload |
DropzoneProps extends ShopifyDropzoneProps
Name | Type | Default | Description |
---|---|---|---|
children | ReactNode | - | Nội dung hiển thị trong UploadFile |
suffixName | string | undefined | - | Thêm chuỗi vào cuối tên file |
onUpload | (callback: () => void) => void | undefined | - | Chạy callback đẻ tiến hành upload file |