Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/src/Http/Controllers/v1/ReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ public function create(CreateReviewRequest $request)
$extension = File::getExtensionFromMimeType($mimeType);
$bucketPath = 'hyperstore/' . $about->public_id . '/review-photos/' . $review->uuid . '/' . File::randomFileName($extension);

// upload file to path
$upload = Storage::disk($disk)->put($bucketPath, base64_decode($data), 'public');
// upload file to path; no 'public' ACL, the S3 media bucket is private and rejects ACLs
$upload = Storage::disk($disk)->put($bucketPath, base64_decode($data));

// create the file
$uploadedFiles->push(File::create([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,17 +774,22 @@ function createReviewControllerSchema(): void
'uuid' => 'owned_review_uuid',
'public_id' => 'review_owned',
]);
Illuminate\Support\Facades\Storage::swap(new class {
$reviewStorage = new class {
public function disk(string $disk): self
{
return $this;
}

public function put(string $path, string $contents, string $visibility): bool
public array $writes = [];

public function put(string $path, string $contents, mixed $options = []): bool
{
$this->writes[] = [$path, $options];

return true;
}
});
};
Illuminate\Support\Facades\Storage::swap($reviewStorage);
session(['storefront_key' => 'store_key']);
$withPhoto = $controller->create(
Fleetbase\Storefront\Http\Requests\CreateReviewRequest::create('/reviews', 'POST', [
Expand Down Expand Up @@ -820,6 +825,9 @@ public function put(string $path, string $contents, string $visibility): bool
->and($photo->bucket)->toBe('review-bucket')
->and($photo->file_size)->toBe(strlen('image-bytes'))
->and($photo->type)->toBe('storefront_review_upload')
// review photos are written without a 'public' visibility/ACL
->and($reviewStorage->writes)->toHaveCount(1)
->and($reviewStorage->writes[0][1])->toBe([])
->and($deleted->resource->uuid)->toBe('owned_review_uuid')
->and($connection->table('reviews')->where('uuid', 'owned_review_uuid')->value('deleted_at'))->not->toBeNull();
});
Expand Down
Loading