Steps:
- Install
@bytescale/upload-widget-react
- Uninstall
react-uploader
anduploader
- Replace
"react-uploader"
with"@bytescale/upload-widget-react"
in yourimport
statements. - Replace
uploader
withupload-widget
in all CSS class name overrides (if you have any). - Replace
onUpdate: (files) => {}
withonUpdate: ({uploadedFiles}) => {}
. - Remove
uploader
(from imports and props) - Add
apiKey
as a field to the object passed to theoptions
prop (add it if you don't have one).
import { Uploader } from "uploader";
import { UploadDropzone } from "react-uploader";
// Get production API keys from Bytescale.com
const uploader = Uploader({
apiKey: "free"
});
// Customize the dropzone UI (see "customization"):
const options = { multi: true };
// Render the file upload dropzone:
const MyDropzoneComponent = () => (
<UploadDropzone
uploader={uploader} // Required.
options={options} // Optional.
width="600px" // Optional.
height="375px" // Optional.
onUpdate={files => {
// Optional.
if (files.length === 0) {
console.log("No files selected.");
} else {
console.log("Files uploaded:");
console.log(files.map(f => f.fileUrl));
}
}}
/>
);
import { UploadDropzone } from "@bytescale/upload-widget-react";
const options = {
apiKey: "free", // Get API keys from: www.bytescale.com
multi: true // Full Config: https://www.bytescale.com/docs/upload-widget#configuration
};
// Render the file upload dropzone:
const MyDropzoneComponent = () => (
<UploadDropzone
options={options} // Required.
width="600px" // Optional.
height="375px" // Optional.
onUpdate={({ uploadedFiles }) => {
// Optional.
if (uploadedFiles.length === 0) {
console.log("No files selected.");
} else {
console.log("Files uploaded:");
console.log(uploadedFiles.map(f => f.fileUrl));
}
}}
/>
);
Bytescale migration guides listed below:
- Migrating from
upload-js
to@bytescale/sdk
- Migrating from
uploader
to@bytescale/upload-widget
- Migrating from
react-uploader
to@bytescale/upload-widget-react
- Migrating from
angular-uploader
to@bytescale/upload-widget-angular
- Migrating from
@upload-io/vue-uploader
to@bytescale/upload-widget-vue
- Migrating from
@upload-io/jquery-uploader
to@bytescale/upload-widget-jquery