Skip to content

Missing mime-type for upload-files (>= PHP 5.5) #28

@jesbro-webbook

Description

@jesbro-webbook

When having a PHP version >= 5.5 (which all production env should have at this point), we end on line 101 for uploading an attachment.

Not setting the mime_type is quite annoying for daily usage in ActiveCollab, which can open images et.al. inlined. When mime_type becomes octet-stream, you have to download them first.

Fast Solution
CURLFile also takes in mime as a second parameter.
https://www.php.net/curlfile

in src/Connector line 101:
$post_data['attachment_' . $counter++] = new CURLFile($path);

should be:
$post_data['attachment_' . $counter++] = new CURLFile($path, $mime_type);

It could also be nice to have a small tutorial on upload-files:

$response = $client->post(
    'upload-files',
    [],
    [[ "/tmp/filename.jpg", mime_content_type("/tmp/filename.jpg') ]]
);
print ($response->getJson());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions