links sollte nun die gesamte APP_URL enthalten
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -57,7 +57,8 @@ class SparkboothUploadController extends Controller
|
|||||||
$gallery,
|
$gallery,
|
||||||
$file,
|
$file,
|
||||||
$base64Payload,
|
$base64Payload,
|
||||||
$request->input('filename')
|
$request->input('filename'),
|
||||||
|
$request
|
||||||
);
|
);
|
||||||
} catch (RuntimeException $exception) {
|
} catch (RuntimeException $exception) {
|
||||||
return $this->respondError($request, $exception->getMessage(), Response::HTTP_UNPROCESSABLE_ENTITY, $gallery);
|
return $this->respondError($request, $exception->getMessage(), Response::HTTP_UNPROCESSABLE_ENTITY, $gallery);
|
||||||
@@ -177,7 +178,8 @@ class SparkboothUploadController extends Controller
|
|||||||
Gallery $gallery,
|
Gallery $gallery,
|
||||||
?UploadedFile $file,
|
?UploadedFile $file,
|
||||||
?string $base64Payload,
|
?string $base64Payload,
|
||||||
?string $preferredFilename
|
?string $preferredFilename,
|
||||||
|
Request $request
|
||||||
): array {
|
): array {
|
||||||
$directory = trim($gallery->images_path, '/');
|
$directory = trim($gallery->images_path, '/');
|
||||||
|
|
||||||
@@ -192,7 +194,7 @@ class SparkboothUploadController extends Controller
|
|||||||
|
|
||||||
$file->storeAs($directory, $filename, 'public');
|
$file->storeAs($directory, $filename, 'public');
|
||||||
|
|
||||||
return [$relativePath, asset('storage/'.$relativePath)];
|
return [$relativePath, $this->buildPublicUrl($relativePath, $request)];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($base64Payload === null) {
|
if ($base64Payload === null) {
|
||||||
@@ -207,7 +209,7 @@ class SparkboothUploadController extends Controller
|
|||||||
throw new RuntimeException('Failed to store uploaded image.');
|
throw new RuntimeException('Failed to store uploaded image.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$relativePath, asset('storage/'.$relativePath)];
|
return [$relativePath, $this->buildPublicUrl($relativePath, $request)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,4 +350,13 @@ class SparkboothUploadController extends Controller
|
|||||||
|
|
||||||
return '<?xml version="1.0" encoding="UTF-8"?><rsp status="fail">'.$errorAttr.'</rsp>';
|
return '<?xml version="1.0" encoding="UTF-8"?><rsp status="fail">'.$errorAttr.'</rsp>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildPublicUrl(string $relativePath, Request $request): string
|
||||||
|
{
|
||||||
|
$relative = Str::start($relativePath, '/');
|
||||||
|
|
||||||
|
$root = config('app.url') ?: $request->getSchemeAndHttpHost();
|
||||||
|
|
||||||
|
return rtrim($root, '/').'/storage'.$relative;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class SparkboothUploadTest extends TestCase
|
|||||||
])
|
])
|
||||||
->assertJsonStructure(['url']);
|
->assertJsonStructure(['url']);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('/storage/uploads/test/', $response->json('url'));
|
||||||
|
|
||||||
$image = Image::first();
|
$image = Image::first();
|
||||||
$this->assertNotNull($image);
|
$this->assertNotNull($image);
|
||||||
$this->assertSame($gallery->id, $image->gallery_id);
|
$this->assertSame($gallery->id, $image->gallery_id);
|
||||||
@@ -107,6 +109,8 @@ class SparkboothUploadTest extends TestCase
|
|||||||
])
|
])
|
||||||
->assertJsonStructure(['url']);
|
->assertJsonStructure(['url']);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('/storage/uploads/base64/', $response->json('url'));
|
||||||
|
|
||||||
Storage::disk('public')->assertExists('uploads/base64/custom.png');
|
Storage::disk('public')->assertExists('uploads/base64/custom.png');
|
||||||
|
|
||||||
$this->assertDatabaseHas('images', [
|
$this->assertDatabaseHas('images', [
|
||||||
|
|||||||
Reference in New Issue
Block a user