Steps:
- Install
@bytescale/sdk
- Uninstall
upload-js
- Replace
"upload-js"
with"@bytescale/sdk"
in yourimport
statements - Replace
Upload({ apiKey })
withnew UploadManager({ apiKey })
- Replace
.uploadFile(file, options)
with.upload({ data: file, ...options })
import { Upload } from "upload-js";
const upload = Upload({ apiKey: "free" });
//
// Uploading files...
//
const { fileUrl } = await upload.uploadFile(file, {
onBegin: ({ cancel }) => {
/* Optional. To cancel, you would call 'cancel()' */
},
...additionalParams
});
//
// Making URLs....
//
upload.url("/my-uploaded-image.jpg", "thumbnail");
//
// JWT authorization...
//
await upload.beginAuthSession("https://my-auth-url", async () => ({ Authorization: "Bearer AuthTokenForMyApi" }));
import { AuthManager, UrlBuilder, UploadManager } from "@bytescale/sdk";
//
// Uploading files...
//
const uploadManager = new UploadManager({
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
apiKey: "free" // Get API keys from: www.bytescale.com
});
const cancellationToken = {
isCancelled: false // Set to 'true' at any point to cancel the upload.
};
const { fileUrl } = await uploadManager.upload({
data: file,
cancellationToken, // optional
...additionalParams
});
//
// Making URLs...
//
UrlBuilder.url({
accountId,
filePath: "/my-uploaded-image.jpg",
options: {
transformation: "preset",
transformationPreset: "thumbnail"
}
});
//
// JWT authorization...
//
await AuthManager.beginAuthSession({
accountId,
authUrl: "https://my-auth-url",
authHeaders: async () => ({ Authorization: "Bearer AuthTokenForMyApi" })
});
Steps:
- Install
@bytescale/sdk
- Uninstall
upload-js-full
- Replace
"upload-js-full"
with"@bytescale/sdk"
in yourimport
statements. - Replace
new Configuration({ apiKey: 'YOUR_API_KEY' })
with{ apiKey: 'YOUR_API_KEY' }
- Remove
accountId
fromuploadManager.upload({...options...})
(it's no-longer required).
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