Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reset the file pointer when setting the inFile

  • Loading branch information...
commit 78c1a92fe62c365aa615e3bd6a243584cbc23cd3 1 parent e329e97
@BenExile authored
View
1  Dropbox/OAuth/Consumer/ConsumerAbstract.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;
}
View
10 examples/putStream.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.