1
0
Fork 0
mirror of synced 2024-06-18 18:54:55 +12:00

fix api to account for non-local storage

This commit is contained in:
Damodar Lohani 2021-11-14 18:50:51 +05:45
parent 436f6b7c77
commit c9595b40dd
2 changed files with 4 additions and 3 deletions

View file

@ -472,7 +472,7 @@ App::post('/v1/functions/:functionId/tags')
}
// Save to storage
$size ??= $device->getFileSize($fileTmpName);
$size ??= Storage::getDevice('self')->getFileSize($fileTmpName);
$path = $device->getPath($tagId.'.'.\pathinfo($fileName, PATHINFO_EXTENSION));
$tag = $dbForInternal->getDocument('tags', $tagId);

View file

@ -616,13 +616,14 @@ App::post('/v1/storage/buckets/:bucketId/files')
}
$device = Storage::getDevice('files');
$localDevice = Storage::getDevice('self');
if (!$upload->isValid($fileTmpName)) {
throw new Exception('Invalid file', 403);
}
// Save to storage
$size ??= $device->getFileSize($fileTmpName);
$size ??= $localDevice->getFileSize($fileTmpName);
$path = $device->getPath($fileId . '.' . \pathinfo($fileName, PATHINFO_EXTENSION));
$path = str_ireplace($device->getRoot(), $device->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path);
@ -659,7 +660,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
}
}
$mimeType = $device->getFileMimeType($path); // Get mime-type before compression and encryption
$mimeType = $localDevice->getFileMimeType($path); // Get mime-type before compression and encryption
$data = '';
// Compression
if ($size <= APP_STORAGE_READ_BUFFER) {