2

Working with files from a third party application in Podio is a pain.

The application i'm making is a replacement for the webform Podio provides.

In some of these webforms, i need the end-user to upload up to 5 or 6 files.

As of right now, you have to make 2 requests per file uploaded to Podio. 1 request to upload the file, and another to attach the file to the item you have created.

This is constantly hitting the PodioRateLimit.

What would be easier, is to compile all the files into 1 array and then upload and attach that.

If this is already possible please provide documentation.

Kjaal
  • 57
  • 8

2 Answers2

4

Uploading files still have to happen one by one and Podio API doesn't support bulk files upload. Yet you don't need to have 2 requests per file uploaded to Podio. It could rather be: [number of files] + 1 request.

So, for creating new item it could be:

  1. upload file 1
  2. upload file 2
  3. upload file 3
  4. upload file 4
  5. create new item with all uploaded files

total number of requests: 5 (number of files + 1)

files = [<array of file names>]
file_ids = []
files.each do |filename|
  uploaded_file = Podio::FileAttachment.upload(File.open(filename), File.basename(filename))
  file_ids << uploaded_file.file_id
end
new_item = Podio::Item.create(<app_id>, 'fields' => {'title' => 'My title'}, 'file_ids' => file_ids)

And for updating existing item it's pretty much the same, just need to call Item.update instead of Item.create.
P.S. Sorry, but example is in Ruby and not PHP

Pavlo - Podio
  • 2,003
  • 2
  • 10
  • 19
  • Well it would surely cut my requests in half, but as stated this is a suggestion for podio to implement bulk uploading of files. Thank you for the suggestion though. – Kjaal Sep 22 '16 at 12:16
  • 1
    Well, Podio is not a file-management tool but much broader solution, so bulk file upload might not be prioritised, but I will pass your request to Podio team :) Also, could you please accept answer if it's useful. This will make future users find it faster. – Pavlo - Podio Sep 22 '16 at 12:52
0

Here is the php working code:

    $field_id = 'photos';
    foreach($photos as $photo){
        // Upload file
        $file = PodioFile::upload("uploads/".$photo, $photo);
        $fileID[] = (int)$file->file_id;
    }


        PodioItem::update((int)$item->item_id, array(
            'fields' => array(
                "photos" => $fileID
            )));
Andreea Onica
  • 315
  • 5
  • 13