file upload

This commit is contained in:
2024-08-19 17:59:08 +03:00
parent c97be8666e
commit 3aa9191cba
2 changed files with 14 additions and 20 deletions
+8 -2
View File
@@ -57,6 +57,9 @@ readonly class RecordService
throw new LucentException("You can't upload a file to a regular record");
}
$fileData = $this->fileService->createFromUrl($schema, $url);
if ($fileData->isDuplicate) {
return $fileData->duplicateId;
}
return $this->create($data, $fileData->recordFile, $edges);
}
@@ -64,13 +67,16 @@ readonly class RecordService
UploadedFile $uploadedFile,
RecordInputData $data,
array $edges
)
): string
{
$schema = $this->channelService->getSchema($data->schemaName)->get();
if ($schema->type !== Type::FILES) {
throw new LucentException("You can't upload a file to a regular record");
}
$fileData = $this->fileService->upload($schema, $uploadedFile);
if ($fileData->isDuplicate) {
return $fileData->duplicateId;
}
return $this->create($data, $fileData->recordFile, $edges);
}
@@ -78,7 +84,7 @@ readonly class RecordService
FileData $fileData,
RecordInputData $data,
array $edges
)
): string
{
$schema = $this->channelService->getSchema($data->schemaName)->get();
if ($schema->type !== Type::FILES) {