Permalink
Browse files

Reset the file pointer when setting the inFile

  • Loading branch information...
1 parent e329e97 commit 78c1a92fe62c365aa615e3bd6a243584cbc23cd3 Ben Tadiar committed Feb 18, 2012
Showing with 9 additions and 2 deletions.
  1. +1 −0 Dropbox/OAuth/Consumer/ConsumerAbstract.php
  2. +8 −2 examples/putStream.php
@@ -261,6 +261,7 @@ public function setInFile($handle)
if(!is_resource($handle) || get_resource_type($handle) != 'stream'){
throw new \Dropbox\Exception('Infile must be a stream resource');
}
+ fseek($handle, 0);
$this->inFile = $handle;
}
@@ -9,12 +9,18 @@
// Require the bootstrap
require_once('bootstrap.php');
-// Open a stream for reading
+// Open a stream for reading and writing
+$stream = fopen('php://temp', 'rw');
+
+// Write some data to the stream
$data = 'This file was uploaded using the Dropbox API!';
-$stream = fopen('data://text/plain,' . $data, 'r');
+fwrite($stream, $data);
// Upload the stream data to the specified filename
$put = $dropbox->putStream($stream, 'api_upload_test.txt');
+// Close the stream
+fclose($stream);
+
// Dump the output
var_dump($put);

0 comments on commit 78c1a92

Please sign in to comment.