Steps:
- Install
@bytescale/upload-widget-vue
- Uninstall
@upload-io/vue-uploader
anduploader
- Replace
"@upload-io/vue-uploader"
with"@bytescale/upload-widget-vue"
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).
<template>
<button @click="uploadFile">Upload a file...</button>
</template>
<script lang="ts">
import { Uploader } from "uploader";
import { openUploadModal } from "@upload-io/vue-uploader";
import type { UploadWidgetConfig, UploadWidgetResult } from "uploader";
import type { PreventableEvent } from "@upload-io/vue-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-vue";
import type { UploadWidgetConfig, UploadWidgetResult } from "@bytescale/upload-widget";
import type { PreventableEvent } from "@bytescale/upload-widget-vue";
// 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
vue-uploader
to@bytescale/upload-widget-vue
- 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