diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index de19590f25..d59d950d93 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -515,6 +515,7 @@ App::post('/v1/storage/buckets/:bucketId/files') } $mimeType = $deviceFiles->getFileMimeType($path); // Get mime-type before compression and encryption + $fileHash = $deviceFiles->getFileHash($path); // Get file hash before compression and encryption $data = ''; // Compression $algorithm = $bucket->getAttribute('compression', COMPRESSION_TYPE_NONE); @@ -548,7 +549,6 @@ App::post('/v1/storage/buckets/:bucketId/files') } $sizeActual = $deviceFiles->getFileSize($path); - $fileHash = $deviceFiles->getFileHash($path); $openSSLVersion = null; $openSSLCipher = null; diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index baef838979..3169077f99 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -57,8 +57,7 @@ trait StorageBase $this->assertEquals('logo.png', $file['body']['name']); $this->assertEquals('image/png', $file['body']['mimeType']); $this->assertEquals(47218, $file['body']['sizeOriginal']); - $this->assertTrue(md5_file(realpath(__DIR__ . '/../../../resources/logo.png')) != $file['body']['signature']); // should validate that the file is encrypted - + $this->assertTrue(md5_file(realpath(__DIR__ . '/../../../resources/logo.png')) == $file['body']['signature']); /** * Test for Large File above 20MB * This should also validate the test for when Bucket encryption @@ -289,7 +288,7 @@ trait StorageBase $this->assertEquals('logo.png', $file['body']['name']); $this->assertEquals('image/png', $file['body']['mimeType']); $this->assertEquals(47218, $file['body']['sizeOriginal']); - $this->assertTrue(md5_file(realpath(__DIR__ . '/../../../resources/logo.png')) != $file['body']['signature']); // should validate that the file is encrypted + $this->assertTrue(md5_file(realpath(__DIR__ . '/../../../resources/logo.png')) == $file['body']['signature']); return ['bucketId' => $bucketId]; }