Question about Uploading Images in Grafana

Hello everyone, is it possible to upload images in Grafana? I found an endpoint to fetch images from a selected directory, but I need to add the ability to upload new images to this directory via a request. Are there any options to implement this?

Here’s the code to fetch the images:

getDataSourceSrv()
      .get('-- Grafana --')
      .then((ds) => {
        ds.listFiles('img/bg', 10).subscribe({
          next: (frame) => {
            const cards = [];
            frame.forEach((item) => {
              const idx = item.name.lastIndexOf('.');
              cards.push({
                value: `img/bg/${item.name}`,
                label: item.name,
                search: (idx ? item.name.substring(0, idx) : item.name).toLowerCase(),
                imgUrl: `public/img/bg/${item.name}`,
              });
            });
            setImgs(cards);
          },
        });
      });

Hi. there’s no current way to push static assets into Grafana. What many panels do is to store the image as a base64 in the plugin options but this won’t scale well.

Could you please advise how I can bypass this, as I need to add the ability to upload images to the img folder from Grafana?

There’s nothing to bypass. the API doesn’t exist.

What I mean is, how correct would it be to create an external API, for example, to save an image in the img folder?

Look at the business text plugin wherein you can use JavaScript to allow you to maybe do what you need

I think this is not what I need :frowning:

Are you developing a plugin that does the saving if images to grafana?

Yes, I am developing a plugin, and I need to add the ability to upload images so that they are saved in the img/ grafana folder.

1 Like