Allow file uploads from explorer
This commit is contained in:
parent
4868b8f8ec
commit
aa7e326ce9
3 changed files with 15 additions and 2 deletions
|
@ -86,6 +86,7 @@ App::post('/v1/graphql')
|
|||
}
|
||||
|
||||
$type = $request->getHeader('content-type');
|
||||
|
||||
if (\str_starts_with($type, 'application/graphql')) {
|
||||
$query = parseGraphql($request);
|
||||
}
|
||||
|
@ -195,6 +196,7 @@ function parseMultipart(array $query, Request $request): array
|
|||
{
|
||||
$operations = \json_decode($query['operations'], true);
|
||||
$map = \json_decode($query['map'], true);
|
||||
|
||||
foreach ($map as $fileKey => $locations) {
|
||||
foreach ($locations as $location) {
|
||||
$items = &$operations;
|
||||
|
@ -207,9 +209,13 @@ function parseMultipart(array $query, Request $request): array
|
|||
$items = $request->getFiles($fileKey);
|
||||
}
|
||||
}
|
||||
|
||||
$query['query'] = $operations['query'];
|
||||
$query['variables'] = $operations['variables'];
|
||||
|
||||
unset($query['operations']);
|
||||
unset($query['map']);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
|
|
@ -417,7 +417,14 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
|||
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Maximum bucket file size is larger than _APP_STORAGE_LIMIT');
|
||||
}
|
||||
|
||||
|
||||
$file = $request->getFiles('file');
|
||||
|
||||
// GraphQL multipart spec adds files with index keys
|
||||
if (empty($file)) {
|
||||
$file = $request->getFiles(0);
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
throw new Exception(Exception::STORAGE_FILE_EMPTY);
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ class StorageClientTest extends Scope
|
|||
]
|
||||
]),
|
||||
'map' => \json_encode([
|
||||
'file' => ["variables.file"]
|
||||
'0' => ["variables.file"]
|
||||
]),
|
||||
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
'0' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
|
||||
];
|
||||
|
||||
$file = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([
|
||||
|
|
Loading…
Reference in a new issue