0

I need to download all the attachments on a Podio app. I can get all the files id and their url, etc.. i just can't make the download. I've tried many possible solutions (get_raw(), file_get_contents, etc..).

Lets say i have this file that i want to save:

$items = PodioFile::get_for_app(APP_ID, array(
        'sort_by' => 'name',
        'sort_desc' => 'false',
        'limit' => 1
    ));

(...)

$item->file_id = '123456789'
$item->link    = 'https://files.podio.com/111222333';

$path_to_save = 'backup/';

How can i save it?

stackrocha
  • 405
  • 2
  • 8

2 Answers2

1

There's an example ready for copy+paste at: http://podio.github.io/podio-php/api-requests/

// Get the file object. Only necessary if you don't already have it!
$file = PodioFile::get($file_id);

// Download the file. This might take a while...
$file_content = $file->get_raw();

// Store the file on local disk
file_put_contents($path_to_file, $file_content);
  • Thank you! I've already try it. It saves a file with +-25kb that doesn't open. All the files have that size (pdf, doc, xls...).. Do you have any other sugestion? – stackrocha Oct 14 '14 at 12:55
  • Put podio-php into debug mode and examine its log, also check your PHP error log for hints. It's most likely a general PHP problem and not soemthing specific to podio-php – Andreas Haugstrup Pedersen Oct 14 '14 at 15:12
0
mkdirs("downloads");
foreach ($podio_item->fields['images']->values as $key => $podio_file) {
    $file         = PodioFile::get($podio_file->file_id);
    $file_content = $file->get_raw();
    file_put_contents("downloads/$podio_image->name", $file_content);
}
Jamie
  • 1
  • 1