[Owncloud] special characters in filenames
Jörn Friedrich Dreyer
jfd at owncloud.com
Thu Aug 2 15:56:11 UTC 2012
On 02.08.2012 17:05, Emre Erenoglu wrote:
> For MD5SUM, a stupid question if I may ask, could the md5sum or any
> other checksum/hash be generated "on the fly" while the file is
> uploaded from sync client, web interface or webdav? This way, we don't
> need to spend additional IO cycles to upload and then hash. :)
I alway wanted to look this up. It seems that instead of using
move_uploaded_file it is preferable to user fopen('php://input') to do
fileuploads[1]:
<?php
if ($_SERVER['REQUEST_METHOD'] =="PUT")
{$f=fopen(basename($_SERVER['REQUEST_URI']),"w");
$s=fopen("php://input","r");
while($kb=fread($s,1024))
{fwrite($f,$kb,1024); }
fclose($f);
fclose($s);
Header("HTTP/1.1 201 Created"); }
elseif ($_SERVER['REQUEST_METHOD'] =="GET")
{readfile(basename($_SERVER['REQUEST_URI'])); }
?>
In a ddition to saving the buffer to a file we could use hash_init,
hash_update and hash_final to create a hash for it without reading the
whole thing again. This would also allow us to save the file directly to
the location we want, without copying it when calling
OC_Helper::streamCopy(), which should by the way use
stream_copy_to_stream instead of reimplementing it, right?
seems nice, wanna implement it?
so long
Jörn
[1] src: http://php.net/manual/de/features.file-upload.put-method.php
--
Jörn Friedrich Dreyer (jfd at owncloud.com)
Software Developer
ownCloud GmbH
Your Data, Your Cloud, Your Way!
ownCloud GmbH, GF: Markus Rex, Holger Dyroff
Schloßäckerstrasse 26a, 90443 Nürnberg, HRB 28050 (AG Nürnberg)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20120802/f667dc12/attachment.html>
More information about the Owncloud
mailing list