update naming
This commit is contained in:
parent
a2ef59df47
commit
e1f45b5a2d
|
@ -441,7 +441,7 @@ App::post('/v1/functions/:functionId/tags')
|
|||
$file = $request->getFiles('code');
|
||||
$device = Storage::getDevice('functions');
|
||||
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
|
||||
$fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
|
||||
$fileSizeValidator = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
|
||||
$upload = new Upload();
|
||||
|
||||
if (empty($file)) {
|
||||
|
@ -451,7 +451,7 @@ App::post('/v1/functions/:functionId/tags')
|
|||
// Make sure we handle a single file and multiple files the same way
|
||||
$fileName = (\is_array($file['name']) && isset($file['name'][0])) ? $file['name'][0] : $file['name'];
|
||||
$fileTmpName = (\is_array($file['tmp_name']) && isset($file['tmp_name'][0])) ? $file['tmp_name'][0] : $file['tmp_name'];
|
||||
$size = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
|
||||
$fileSize = (\is_array($file['size']) && isset($file['size'][0])) ? $file['size'][0] : $file['size'];
|
||||
|
||||
if (!$fileExt->isValid($file['name'])) { // Check if file type is allowed
|
||||
throw new Exception('File type not allowed', 400);
|
||||
|
@ -465,23 +465,23 @@ App::post('/v1/functions/:functionId/tags')
|
|||
if (!empty($contentRange)) {
|
||||
$start = $request->getContentRangeStart();
|
||||
$end = $request->getContentRangeEnd();
|
||||
$size = $request->getContentRangeSize();
|
||||
$fileSize = $request->getContentRangeSize();
|
||||
$tagId = $request->getHeader('x-appwrite-id', $tagId);
|
||||
if(is_null($start) || is_null($end) || is_null($size)) {
|
||||
if(is_null($start) || is_null($end) || is_null($fileSize)) {
|
||||
throw new Exception('Invalid content-range header', 400);
|
||||
}
|
||||
|
||||
if ($end == $size) {
|
||||
if ($end == $fileSize) {
|
||||
//if it's a last chunks the chunk size might differ, so we set the $chunks and $chunk to notify it's last chunk
|
||||
$chunks = $chunk = -1;
|
||||
} else {
|
||||
// Calculate total number of chunks based on the chunk size i.e ($rangeEnd - $rangeStart)
|
||||
$chunks = (int) ceil($size / ($end + 1 - $start));
|
||||
$chunks = (int) ceil($fileSize / ($end + 1 - $start));
|
||||
$chunk = (int) ($start / ($end + 1 - $start)) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileSize->isValid($size)) { // Check if file size is exceeding allowed limit
|
||||
if (!$fileSizeValidator->isValid($fileSize)) { // Check if file size is exceeding allowed limit
|
||||
throw new Exception('File size not allowed', 400);
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ App::post('/v1/functions/:functionId/tags')
|
|||
}
|
||||
|
||||
// Save to storage
|
||||
$size ??= Storage::getDevice('self')->getFileSize($fileTmpName);
|
||||
$fileSize ??= Storage::getDevice('self')->getFileSize($fileTmpName);
|
||||
$path = $device->getPath($tagId.'.'.\pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
|
||||
$tag = $dbForInternal->getDocument('tags', $tagId);
|
||||
|
@ -509,7 +509,7 @@ App::post('/v1/functions/:functionId/tags')
|
|||
}
|
||||
|
||||
if($chunksUploaded == $chunks) {
|
||||
$size = $device->getFileSize($path);
|
||||
$fileSize = $device->getFileSize($path);
|
||||
|
||||
if ($tag->isEmpty()) {
|
||||
$tag = $dbForInternal->createDocument('tags', new Document([
|
||||
|
@ -520,11 +520,11 @@ App::post('/v1/functions/:functionId/tags')
|
|||
'dateCreated' => time(),
|
||||
'command' => $command,
|
||||
'path' => $path,
|
||||
'size' => $size,
|
||||
'size' => $fileSize,
|
||||
'search' => implode(' ', [$tagId, $command]),
|
||||
]));
|
||||
} else {
|
||||
$tag = $dbForInternal->updateDocument('tags', $tagId, $tag->setAttribute('size', $size));
|
||||
$tag = $dbForInternal->updateDocument('tags', $tagId, $tag->setAttribute('size', $fileSize));
|
||||
}
|
||||
} else {
|
||||
if($tag->isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue