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

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
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

59 views 0 5
Read article

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