I am trying to add attachments to a task using the php asana library (https://github.com/Asana/php-asana). I am successful in 'adding' the files, but when I open them in the task they are completely empty or corrupt.
I have tried .png, .doc, and .pdf all with the same result. My request looks like this:
$attachment = $client->attachments->createOnTask(
$task->id,
'screenshot_from_2016-07-08_140457.png',
'http://edit.local.org/sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_8.png',
'image/png'
);
I have also tried using the relative path for the filename /sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_8.png
but get the same result.
This is the 'example code' I used from the library, seems pretty straightforward.
// add an attachment to the task
$demoAttachment = $client->attachments->createOnTask(
$demoTask->id,
"hello world",
"upload.txt",
"text/plain"
);
Also tried using 2 versions of the the curl request in https://asana.com/developers/api-reference/attachments just to see if I could get the attachments to work at all.
First one:
curl -H "Authorization: Bearer <personal_access_token>" https://app.asana.com/api/1.0/tasks/152938418205845/attachments --form "file=@http://edit.local.org/sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_12.png;type=image/png"
Resulted in
curl: (26) couldn't open file "http://edit-fca.local.org/sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_12.png"
And I've 777 on the file and the folder the file is in. So I decided to remove the '@' in front of the file and then got:
{"errors":[{"message":"file: File is not an object","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}
which when I went to that URL didn't really tell me anything about the File not an object error.
A bit stuck as the php-asana library seems to at least put the files there, but they are empty. While the curl request just seems to not work at all.
Btw I'm using php 5.5.9.