Hi, I’m having trouble to upload a file through Grafana getBackendSrv().
I have a DataSource plugin, where I should upload files from the frontend to it. In order to do this, I set a route at the plugin.json
file, routing to the appropriate endpoint of my service.
What happened is that, if I use Grafana’s getBackendSrv()
it simply fails to send the FormData object, sending a file=%5Bobject+File%5D
content.
Here is a snippet:
async uploadSystem(file: File) {
const endpoint = Collections['applyManualUpdate'];
const url = this.route_endpoint + endpoint;
let formData = new FormData();
formData.append('file', file);
return await getBackendSrv()
.fetch({
url: url,
data: formData,
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
})
.toPromise();
}
Is it not possible to send files through this method at all?