How to use box with salesforce LWC?
Hi, I need to use box Content Uploader API in lwc,
My Js code as follows. When I
When I run it, I get an undefine error when I download uploader.js.
How can I solve this problem? please give me some suggestions
I downloaded the uploader.js、uploader.css as follows, and I uploaded them to static resource.
https://cdn01.boxcdn.net/platform/elements/15.0.0/en-US/uploader.js
https://cdn01.boxcdn.net/platform/elements/15.0.0/en-US/uploader.css
JS code:
import { LightningElement } from 'lwc';
import { loadStyle, loadScript } from 'lightning/platformResourceLoader';
import LwcUploader_15_React from '@salesforce/resourceUrl/LwcUploader_15_React';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class LwcCallBoxUIElement extends LightningElement {
uploader;
accessToken = "";
fileId = "";
fileName = "";
connectedCallback() {
Promise.all([
loadStyle(this, LwcUploader_15_React + '/uploader.css').then(() => console.log("uploader.css loaded")),
loadScript(this, LwcUploader_15_React + '/uploader.js').then(() => console.log("uploader.js loaded"))-----★エラー発生行目
])
.then(() => {
window.console.log("js Load OK");
this.setUploader();
})
.catch((error) => {
window.console.log("js Load Error : " + error);
this.dispatchEvent(
new ShowToastEvent({
title: 'Error in loading LwcUploader',
message: 'message: ' + error,
variant: 'error'
})
);
});
}
setUploader() {
const { ContentUploader } = Box;
uploader = new ContentUploader();
uploader.on('complete',(data)=>{
console.log(data);
//uploader.hide();
fileId = data[0].id;
fileName = data[0].name;
});
uploader.on('error',(data)=>{
console.log(data);
alert('ファイルアップロードエラー');
});
uploader.on('close',(e)=>{
console.log(e);
});
}
}
-
Hi,
Did you try with uploader.no.react.js ?
https://developer.box.com/guides/embed/ui-elements/installation/
Post is closed for comments.
Comments
1 comment