How do I store images and make them available with a URL in a plugin?

Matthías Orri Ólafsson October 12, 2015

Greetings JIRA plugin developers,

 

I have been looking for a couple of days for an answer to this question but to no avail. 

In a plugin I am writing I need to be able upload images after the plugin has been installed, store them and then be able to access them with a URL so they can be presented at a different point in the plugin. I have already achieved the storage of the image in a JIRA_HOME/data/{mypluginfolder}  directory. I can see the uploaded images in this folder on my local developer instance of JIRA, but I have no ideas how to make the images accessible to the JIRA user/plugin so they can presented/retrieved. I have thought about making a rest call that would fetch the images and present them, but I understand that solution would be very memory consuming. Does anyone have any suggestions on how to do what I am trying to achieve?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Dang Thi Thuy Tien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2019

I resolve this problem by that way:

- Upload image -> store image in JIRA HOME  -> read image from JIRAHOME -> return it to client via REST 

if (FileUtil.isImage(image)) {
String subType = FileUtil.getFileExtension(fileName);
return Response.ok(image).type(new MediaType("image", subType)).build();
}
0 votes
Vitalii Petrychuk
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2015

Hi Matthías,

Have you tried to define a downloadable directory in your atlassian-plugin.xml? This doc is for Bamboo but should work with JIRA as well.

https://developer.atlassian.com/bamboodev/bamboo-plugin-guide/downloadable-plugin-resources#DownloadablePluginResources-DefiningaDirectoryofDownloadableResources

If your plugin requires a lot of resources, you may wish to expose a directory of files as resources, rather than writing definitions for each individual file.

<resource type="download" name="icons/" location="templates/extra/autofavourite/icons/"/>
  • The name and location must both have trailing slashes
  • Subdirectories are also exposed, so in the example above, icons/small/icn_auto_fav.gif will be mapped to the resourcetemplates/extra/autofavourite/icons/small/icn_auto_fav.gif
Matthías Orri Ólafsson October 14, 2015

Greetings Vitalii, I wasn't aware that I could access and alter a resource folder after the plugin has been installed. I need to be able to upload content to the folder at any point after the plugin's installation. If it is possible I can clearly see how this would be a good solution.

Deborah Falcone November 28, 2016

Hi Matthías, have you solved this problem? I have the same aim. I've tried the solution proposed by Vitalii Petrychuk but it doesn't work! Thank you

Dang Thi Thuy Tien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 2, 2018

HI  Matthías, have you solves this probleam? I have the same probleam. I try to find a lot of way but it doesn't work. Thank you.

IgorUkolov February 18, 2019

Any updates on this? I have the same trouble to get this done...

TAGS
AUG Leaders

Atlassian Community Events