Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to display attached image

smith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 2, 2020

hi

I got the image url attached to the issue from the rest api.
http://xxx.xxx.xxx.xxx:xxxx/secure/attachment/10100/Image1.jpg

I am trying to view an image using Glide on android.

But it was not shown, so I checked it with a browser
The login screen appears.

Maybe it's an authentication problem.
I added the code to the header.
As follows

String url = "http://xxx.xxx.xxx.xxx:xxxx/secure/attachment/10100/Image1.jpg"
String userInfo = "userid:password";
String basicAuth = "Basic " + new String(Base64.encode(userInfo.getBytes(), userInfo.getBytes().length));

GlideUrl glideUrl = new GlideUrl(url,
new LazyHeaders.Builder()
.addHeader("Authorization", basicAuth)
.build());

Glide.with(this)
.load(glideUrl)
.into(imageview);


But I still get an error.
What should I do?

thank you.

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 8, 2020

Hello @smith ,

Welcome to the Atlassian Community!

If I understand correctly you are trying to download an attachment using REST API, but this is failing. 

Now, if this is the case, I believe the root-cause is one of the following:

  1. You are using username and password to authenticate your REST API call, while you should be using an Atlassian account email address and API token  (for details see:  Basic auth for REST APIs)
  2. You are not following redirects

 

In order to double-check, please try to download the attachment using Curl (the -L option is to follow redirects, the -o to set the output filename):

curl -u <EMAIL-ADDRESS>:<API-TOKEN> -D- -L -X GET "https://xxxxxx.atlassian.net/secure/attachment/10010/Image1.jpg" -o filename.jpg

 

If this works then just update your code accordingly. If it does not work, please paste the output in your reply (removing sensitive data).

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events