Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting image content from Jira

I'm trying to extract image content from Jira using the REST API. Using the 'attachment' field I can get all the meta data about the image, including filename, size,mimeType, content Url, thumbnail url etc.

But I need to be able to download the image itself. Putting the content url into  a browser downloads the image ok, but only because I happen to logged into Jira.

So I'm using PHP CURL to download the image from this url and I'm hoping that the following code should do it:

$ch = curl_init($url);
$tempPath = '/tmp/jira_' . uniqid(true) ;
$fp = fopen($tempPath, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_USERPWD, "me@mysite.com:$this->_apiKey" );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );

curl_exec($ch);
fclose($fp);

I'm using the CURLOPT_USERPWD in the same way I do when using the rest API, but the file is always empty. I'm assuming that this is an authentication issue. Can anybody tell me how I am supposed to authenticate?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

3,962 views 11 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you