Change format for upload
This commit is contained in:
parent
a6c11cdc14
commit
59d7647720
|
@ -50,6 +50,9 @@ class MediaController
|
|||
$file = new MediaFile($c['name']);
|
||||
$file->setBasename($collection->runCallback('forceFileName', $model, $file->getBasename()));
|
||||
|
||||
if ($collection->runCallback('convert') !== null) {
|
||||
$file->setExtension($collection->runCallback('convert'));
|
||||
}
|
||||
$adder = $this->fileAdderFromData($model, $c['content'], $collection)
|
||||
->usingName($file->getBasename())
|
||||
->usingFileName($file->getFilename())
|
||||
|
|
|
@ -34,6 +34,25 @@ test('it uploads a single file to a single file collection', function () {
|
|||
$response->assertJsonMissingPath('model_id');
|
||||
});
|
||||
|
||||
test('it changes format', function () {
|
||||
$this->auth()->registerModel();
|
||||
$post = $this->newPost();
|
||||
$content = base64_encode($this->pngFile()->getContent());
|
||||
|
||||
$response = $this->postJson('/mediaupload', [
|
||||
'parent' => ['model' => 'post', 'collection_name' => 'singleJpegFile', 'id' => $post->id],
|
||||
'payload' => [
|
||||
'content' => $content,
|
||||
'name' => 'beispiel bild.png',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertStatus(201)
|
||||
->assertJsonPath('size', 366471)
|
||||
->assertJsonPath('file_name', 'beispiel-bild.jpg')
|
||||
->assertJsonPath('mime_type', 'image/jpeg');
|
||||
});
|
||||
|
||||
test('it uploads a single image to a single file collection', function () {
|
||||
$this->auth()->registerModel()->withoutExceptionHandling();
|
||||
$post = $this->newPost();
|
||||
|
|
Loading…
Reference in New Issue