From 49217d121182c5a98d17bfba9c16fc0551e2e734 Mon Sep 17 00:00:00 2001 From: ksacry Date: Tue, 14 Aug 2012 11:13:35 -0600 Subject: [PATCH 1/2] chunk verification fails on upload The response from vimeo is either an array of objects if using chunks, or just one array with id and size if using one chunk. --- vimeo.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vimeo.php b/vimeo.php index b845db2..9bac47f 100644 --- a/vimeo.php +++ b/vimeo.php @@ -477,12 +477,18 @@ public function upload($file_path, $use_multiple_chunks = false, $chunk_temp_dir $verify = $this->call('vimeo.videos.upload.verifyChunks', array('ticket_id' => $ticket)); // Make sure our file sizes match up - foreach ($verify->ticket->chunks as $chunk_check) { - $chunk = $chunks[$chunk_check->id]; - - if ($chunk['size'] != $chunk_check->size) { + if($use_multiple_chunks){ + foreach ($verify->ticket->chunks->chunk as $chunk_check) { + $chunk = $chunks[$chunk_check->id]; + if ($chunk['size'] != $chunk_check->size) { // size incorrect, uh oh - echo "Chunk {$chunk_check->id} is actually {$chunk['size']} but uploaded as {$chunk_check->size}
"; + echo "Chunk {$chunk_check->id} is actually {$chunk['size']} but uploaded as {$chunk_check->size}
"; + } + } + }else{ + $chunk_check = $verify->ticket->chunks->chunk; + if ($chunks[0]['size'] != $chunk_check['size']){ + echo "Chunk {0} is actually {$chunk['size']} but uploaded as {$chunk_check['size']}
"; } } From 428b4f631e1f78fc828061a9ffe3e733ac86cc17 Mon Sep 17 00:00:00 2001 From: ksacry Date: Fri, 24 Aug 2012 14:44:44 -0600 Subject: [PATCH 2/2] chunking with only one chunk failed to verify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I was originally just checking if chunks where used to determine if the return was an array of classes or just an array. This failed if there was only one chunk. This now checks for  the key 0 meaning it's an array of objects. --- vimeo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vimeo.php b/vimeo.php index 9bac47f..e8ac23c 100644 --- a/vimeo.php +++ b/vimeo.php @@ -477,7 +477,7 @@ public function upload($file_path, $use_multiple_chunks = false, $chunk_temp_dir $verify = $this->call('vimeo.videos.upload.verifyChunks', array('ticket_id' => $ticket)); // Make sure our file sizes match up - if($use_multiple_chunks){ + if(array_key_exists(0, $verify->ticket->chunks->chunk)){ foreach ($verify->ticket->chunks->chunk as $chunk_check) { $chunk = $chunks[$chunk_check->id]; if ($chunk['size'] != $chunk_check->size) {