How can I programmatically update project avatar in JIRA 7, before JIRA 7, i was catching my newly created projects with project hook and using AvatarManager.create(String fileName, String contentType, Project owner, InputStream image, Selection selection) method, and then updating the project with the newly created avatar.
Community moderators have prevented the ability to post new answers.
Finally I got it to work.
I had to use this approach:
final Avatar newAvatar = AvatarImpl.createCustomAvatar("avatar-name.png", "image/png", project);
final Avatar createdAvatar = this.avatarManager.create(newAvatar, imageStream, null);
Don't know why the other one didn't work.
Thank you for sharing!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Volodymyr,
Thank you for you answer.
I am using the same approach, but I get js error that the resource could not be found (the project avatar icon).
I debugged the code, and everything is being set properly( my image is being properly created as avatar and than being updated to the project).
So I was wondering does anyone else have the same problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please check the image link for your avatar. Maybe it passes wrong avatar.id. One more: do you see that the avatar file was created in JIRA filesystem. I do not remember exact path but I remember I was able to track it under /target folder when I was coding avatar uploading.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure what you mean by image link, but the id of the created avatar, matches the one sent to updateProject method, and after that method, i retrieve that project, and it has the correct avatar id. Yes there are couple of images generated at : target\jira\home\data\avatars p.s.Sorry for long time to answer but I have a 24h hour post limit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Added a new answer to be able to attach the image. Also voted you up so you can post.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Milan,
What does stop you in JIRA 7?
There still is AvatarManager.create with the parameters you mentioned. and there is ProjectManager.updateProject that has parameter for avatarId.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.