我想使用php asana庫(https://github.com/Asana/php-asana)將附件添加到任務。我成功地添加了這些文件,但是當我在任務中打開它們時,它們完全是空的或者已經損壞了。添加附件到使用php asana庫的任務導致任務中的空文件
我曾嘗試巴紐,.DOC和.pdf都具有相同的結果。我的要求是這樣的:
$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'
);
我也使用文件名/sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_8.png
的相對路徑嘗試,但得到相同的結果。
這是我從庫中使用的'示例代碼',看起來很簡單。
// add an attachment to the task
$demoAttachment = $client->attachments->createOnTask(
$demoTask->id,
"hello world",
"upload.txt",
"text/plain"
);
使用2個版本https://asana.com/developers/api-reference/attachments的捲曲請求,只是爲了看看,如果我能得到的附件在所有的工作也試過。
第一個:
curl -H "Authorization: Bearer <personal_access_token>" https://app.asana.com/api/1.0/tasks/152938418205845/attachments --form "[email protected]://edit.local.org/sites/default/files/webform/change-request-materials/screenshot_from_2016-07-08_140457_12.png;type=image/png"
導致在
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"
我上的文件和文件所在的文件夾已經777所以我決定刪除「@」在前面該文件,然後拿到了:
{"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"}]}
,當我去到該網址沒有真正告訴我有關文件不是什麼OBJ等錯誤。
由於php-asana庫似乎至少會將文件放在那裏,但它們是空的。雖然curl請求似乎根本不起作用。
btw我使用php 5.5.9。