Steps:
- Install
@bytescale/upload-widget-jquery
- Uninstall
@upload-io/jquery-uploader
anduploader
- Replace
"@upload-io/jquery-uploader"
with"@bytescale/upload-widget-jquery"
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) - Remove
$.uploader.init(...)
- Replace
.uploader({...})
with.bytescaleUploadWidget({...})
- Add
apiKey
as a field to the object passed to thebytescaleUploadWidget
method (add it if you don't have one).
<template>
<button @click="uploadFile">Upload a file...</button>
</template>
<script lang="ts">
import { Uploader } from "uploader";
import { openUploadModal } from "@upload-io/jquery-uploader";
import type { UploadWidgetConfig, UploadWidgetResult } from "uploader";
import type { PreventableEvent } from "@upload-io/jquery-uploader";
// Create one instance per app. (Get API keys from Bytescale)
const uploader = Uploader({
apiKey: "free"
});
// See "customization" below.
const options: UploadWidgetConfig = {
multi: true
};
export default {
name: "App",
methods: {
uploadFile(event: PreventableEvent) {
openUploadModal({
event,
uploader,
options,
onComplete: (files: UploadWidgetResult[]) => {
if (files.length === 0) {
alert("No files selected.");
} else {
alert(files.map(f => f.fileUrl).join("\n"));
}
}
})
}
}
};
</script>
<template>
<button @click="uploadFile">Upload a file...</button>
</template>
<script lang="ts">
import { openUploadModal } from "@bytescale/upload-widget-jquery";
import type { UploadWidgetConfig, UploadWidgetResult } from "@bytescale/upload-widget";
import type { PreventableEvent } from "@bytescale/upload-widget-jquery";
// Full Configuration:
// https://www.bytescale.com/docs/upload-widget#configuration
const options: UploadWidgetConfig = {
apiKey: "free", // Get API keys from: www.bytescale.com
maxFileCount: 10
};
export default {
name: "App",
methods: {
uploadFile(event: PreventableEvent) {
openUploadModal({
event,
options,
onComplete: (files: UploadWidgetResult[]) => {
if (files.length === 0) {
alert("No files selected.");
} else {
alert(files.map(f => f.fileUrl).join("\n"));
}
}
})
}
}
};
</script>
Bytescale migration guides listed below:
- Migrating from
upload-js
to@bytescale/sdk
- Migrating from
uploader
to@bytescale/upload-widget
- Migrating from
jquery-uploader
to@bytescale/upload-widget-jquery
- 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