Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2020-02-07 16:22:12 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2020-04-13 13:57:27 +0300
commitc2677682c4a3886f8316bfae120dc1b2fbde39ac (patch)
tree88297af92e4416fbb197f255f58bf229ab527cf1 /apps/dav/lib/Connector/Sabre/File.php
parent6187cea3044a2d3406f1d89c04d00ad5a299932e (diff)
Return hashes of uploaded content for dav uploads
hashes are set in "X-Hash-MD5", "X-Hash-SHA1" and "X-Hash-SHA256" headers. these headers are set for file uploads and the MOVE request at the end of a multipart upload. Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/File.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 2c108819e9f..a7a2470b4f6 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -41,6 +41,7 @@ namespace OCA\DAV\Connector\Sabre;
use Icewind\Streams\CallbackWrapper;
use OC\AppFramework\Http\Request;
use OC\Files\Filesystem;
+use OC\Files\Stream\HashWrapper;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Exception\EntityTooLarge;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
@@ -173,16 +174,26 @@ class File extends Node implements IFile {
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
}
- if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
- if (!is_resource($data)) {
- $tmpData = fopen('php://temp', 'r+');
- if ($data !== null) {
- fwrite($tmpData, $data);
- rewind($tmpData);
- }
- $data = $tmpData;
+ if (!is_resource($data)) {
+ $tmpData = fopen('php://temp', 'r+');
+ if ($data !== null) {
+ fwrite($tmpData, $data);
+ rewind($tmpData);
}
+ $data = $tmpData;
+ }
+ $data = HashWrapper::wrap($data, 'md5', function ($hash) {
+ $this->header('X-Hash-MD5: ' . $hash);
+ });
+ $data = HashWrapper::wrap($data, 'sha1', function ($hash) {
+ $this->header('X-Hash-SHA1: ' . $hash);
+ });
+ $data = HashWrapper::wrap($data, 'sha256', function ($hash) {
+ $this->header('X-Hash-SHA256: ' . $hash);
+ });
+
+ if ($partStorage->instanceOfStorage(Storage\IWriteStreamStorage::class)) {
$isEOF = false;
$wrappedData = CallbackWrapper::wrap($data, null, null, null, null, function ($stream) use (&$isEOF) {
$isEOF = feof($stream);