跑道 API 项目图片上传

Podio API image upload on item

希望能在这里得到一些帮助。我可以通过 API 上传图像文件,并且收到 file_id 作为响应,但每次我尝试使用返回的 id 更新项目中的图像字段时,我都会得到:

"File with mimetype application/octet-stream is not allowed, must match one of (MimeTypeMatcher('image', ('png', 'x-png', 'jpeg', 'pjpeg', 'gif', 'bmp', 'x-ms-bmp')),)

我什至在我的 PHP 脚本中添加了一行代码以从文件中提取 jpeg,在上传之前将其重写为 jpeg 以确定( imagejpeg())。尽管如此,当我开始更新项目的图像字段时,我还是遇到了同样的错误。似乎所有通过 API 上传的图像都被转换为八位字节流。我该如何解决这个问题? 我正在使用跑道 PHP 库。

PHP代码如下:

$fileName = "testUpload.jpeg";
imagejpeg(imagecreatefromstring(file_get_contents($fileName)),$fileName);
$goFile = PodioFile::upload($fileName,$itemID);
$fileID = $goFile->file_id;

PodioItem::update((int)$itemID, array(
        'fields' => array(
            "logo" => (int)$fileID,
        )
    ) , array(
        "hook" => 0
    ));

请尝试更换:

$goFile = PodioFile::upload($fileName,$itemID);

与类似的东西:

$goFile = PodioFile::upload('/path/to/example/file/example.jpg', 'example.jpg');
$fileID = $goFile->file_id;
PodioItem::update((int)$itemID, array(
    'fields' => array(
        "logo" => array((int)$fileID),
    )

https://developers.podio.com/examples/files#subsection_uploading中所述 然后像您使用的那样使用 $fileID 。是的,filename 也应该有文件扩展名,所以它不能只与 123123123 一起使用,但应该与 123123123.jpg

一起工作