Search code examples
podio

Can't access uploaded files via Podio API


We actually want to upload a file and attach it to an item but we're having problems just uploading it.

We are having a problem uploading an image into an item. We cant seem to access the image we uploaded to Podio via the API. We get a - "Sorry, you don't have access to this file. You might want to ask your admin to provide you the access to this file."

Which is so weird because everyone in our team cant access it, and we're admins on our workspaces. I also setup the api/secret keys and i'm and admin on that workspace. Whats wrong with this?

This is the code:

Podio::setup($client_id, $client_secret);

try {

    Podio::authenticate_with_app($app_id, $app_token);

    $upload = PodioFile::upload('PATH_TO_FILE', 'test_image.jpg');

    if( $upload != ""){
        echo "<br><br>Image uploaded to podio!<br><br>";
        echo "<pre>".$upload."</pre>";
        echo "<br><br>".$upload->file_id."<br>";
        echo $upload->link."<br>";
    }

    if( PodioFile::attach( $upload->file_id, array('ref_type' => 'item', 'ref_id' => 43 )) != ""){
        echo "<br><br>Image attached to item!<br>";
    }

}catch (PodioError $e) {
    echo $e->body['error_description'];
}

Podio::set_debug(true);

Solution

  • You can't access file itself until it's linked to something because files don't have own access-control system. Once file is attached to item or task or workspace or whatever else, then you might be able to access it if you have enough rights :).

    There is at least one error item_id=43 is for sure not your item, so you can't attach file to it.