Getting an issue with a custom plugin, I have checked the BasePlugin interface and there is no property there called update
import { v4 } from 'uuid';
import { FirebaseStorage, getDownloadURL, ref, uploadBytesResumable } from "firebase/storage";
import { storage } from '@/lib/firebase';
export default class FirebaseCloudStoragePlugin extends BasePlugin {
type: string;
id: string;
title: string;
storageRef: FirebaseStorage;
// @ts-ignore
constructor(uppy: Uppy, opts) {
// @ts-ignore
super(uppy, opts);
this.type = "uploader";
this.id = "FirebaseCloudStorage";
this.title = "Firebase Cloud Storage";
this.storageRef = storage;
this.uploadFile = this.uploadFile.bind(this);
}
async uploadFile(fileIds: string[]) {
await Promise.all(
fileIds.map((id: string) => {
return new Promise<void>(async (resolve, reject) => {
const file = this.getFile(id);
const refId = v4();
const fileRef = ref(this.storageRef, refId);
const metaData = {
contentType: file.type
};
this.emit("upload-started", file);
const uploadTask = uploadBytesResumable(fileRef, file.data, metaData);
uploadTask.on(
"state_changed",
snapshot => {
const progressInfo = {
uploader: this,
bytesUploaded: snapshot.bytesTransferred,
bytesTotal: snapshot.totalBytes
};
this.emit("upload-progress", file, progressInfo);
},
error => {
this.emit("upload-error", file, error);
reject(error);
},
() => {
getDownloadURL(fileRef).then((downloadUrl: string) => {
const file = this.getFile(id);
this.emit(
"upload-success",
{ ...file, downloadUrl },
uploadTask.snapshot,
downloadUrl
);
resolve();
});
}
);
});
})
);
}
install() {
this.addUploader(this.uploadFile);
}
uninstall() {
this.removeUploader(this.uploadFile);
}
}
Expected behavior
I believe that it should render fine. The issue I am finding though is that the error makes sense, if you check the BasePlugin interface, there is no update function there.
This is the code that is causing the bug:
updateAll(state) {
this.iteratePlugins(plugin => {
plugin.update(state);
});
}
Can be found in @uppy/core/lib/Uppy.js
line 261.
I assume that I need to add an update function to the class I have created but type defs won’t allow it because the BasePlugin interface hasn’t got it defined.
Actual behavior
Should Either let me create my own function or ignore the update?