Skip to content

Commit 879329d

Browse files
committed
self review feedback
1 parent 239e376 commit 879329d

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎src/Uploads/AzureBlockBlobChunkWriteHandler.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function store(ChunkUploadRequest $chunkUploadRequest, string $content):
4141
return;
4242
}
4343

44-
$contentType = $manifest->contentType() ?? 'application/octet-stream';
44+
$fileContentType = $manifest->fileContentType() ?? 'application/octet-stream';
4545
$options = new CommitBlockListOptions(
46-
new BlobHttpHeaders(contentType: $contentType)
46+
new BlobHttpHeaders(contentType: $fileContentType)
4747
);
4848
$blockBlobClient->commitBlockList($chunkCollection->orderedReferences(), $options);
4949

‎src/Uploads/AzureChunkManifest.php‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ final class AzureChunkManifest
1010
private function __construct(
1111
private int $uploadLength,
1212
private array $partsByOffset,
13-
private readonly ?string $contentType
13+
private readonly ?string $fileContentType
1414
) {
1515
}
1616

1717
/**
1818
* Null means that initialization did not supply a file MIME type.
1919
* Older manifests also omit it; Azure then uses application/octet-stream.
2020
*/
21-
public static function empty(?string $contentType = null): self
21+
public static function empty(?string $fileContentType = null): self
2222
{
23-
return new self(0, [], $contentType);
23+
return new self(0, [], $fileContentType);
2424
}
2525

2626
public static function fromJson(string $json): self
@@ -37,11 +37,11 @@ public static function fromJson(string $json): self
3737
throw new \RuntimeException('Invalid Azure block blob chunk upload manifest.');
3838
}
3939

40-
$contentType = $decoded['content_type'] ?? null;
41-
if ($contentType !== null && !is_string($contentType)) {
40+
$fileContentType = $decoded['content_type'] ?? null;
41+
if ($fileContentType !== null && !is_string($fileContentType)) {
4242
throw new \RuntimeException('Invalid Azure block blob content type.');
4343
}
44-
$manifest = new self($uploadLength, [], $contentType);
44+
$manifest = new self($uploadLength, [], $fileContentType);
4545

4646
foreach ($chunks as $chunk) {
4747
if (!is_array($chunk)) {
@@ -87,9 +87,9 @@ public function uploadLength(): int
8787
return $this->uploadLength;
8888
}
8989

90-
public function contentType(): ?string
90+
public function fileContentType(): ?string
9191
{
92-
return $this->contentType;
92+
return $this->fileContentType;
9393
}
9494

9595
/**
@@ -118,8 +118,8 @@ public function toJson(): string
118118
$this->parts()
119119
),
120120
];
121-
if ($this->contentType !== null) {
122-
$payload['content_type'] = $this->contentType;
121+
if ($this->fileContentType !== null) {
122+
$payload['content_type'] = $this->fileContentType;
123123
}
124124

125125
$json = json_encode($payload);

‎src/Uploads/TemporaryUploadService.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function storeUploadedFile(UploadedFile $file): ?string
4343
public function initializeChunkUpload(array|string|null $uploadName, ?string $fileContentType = null): string
4444
{
4545
$fileLocation = $this->uploadPathResolver->buildChunkInitializationPath($uploadName);
46-
$this->storeAzureContentType($fileLocation, $fileContentType);
46+
$this->storeAzureFileContentType($fileLocation, $fileContentType);
4747

4848
return $this->serverIdCodec->encode($fileLocation);
4949
}
5050

51-
private function storeAzureContentType(string $filePath, ?string $fileContentType): void
51+
private function storeAzureFileContentType(string $filePath, ?string $fileContentType): void
5252
{
5353
if ($fileContentType === null) {
5454
return;

‎tests/Feature/AzureOssChunkUploadTest.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ public static function contentTypes(): array
6464
}
6565

6666
#[DataProvider('contentTypes')]
67-
public function test_azure_commit_uses_the_file_mime_type_or_binary_default(?string $contentType, ?string $expectedContentType): void
67+
public function test_azure_commit_uses_the_file_mime_type_or_binary_default(?string $requestContentType, ?string $expectedFileContentType): void
6868
{
6969
$headers = ['Upload-Name' => 'manual.pdf'];
70-
if ($contentType !== null) {
71-
$headers['Content-Type'] = $contentType;
70+
if ($requestContentType !== null) {
71+
$headers['Content-Type'] = $requestContentType;
7272
}
7373
$response = $this->post('/filepond/api/process', ['file' => ['{}']], $headers)->assertOk();
7474
$id = $response->getContent();
7575
$path = app(Filepond::class)->getPathFromServerId($id);
7676
$manifestPath = config('filepond.chunks_path').'/'.sha1($path).'/manifest.json';
77-
$this->assertSame($expectedContentType !== null, $this->storage->exists($manifestPath));
77+
$this->assertSame($expectedFileContentType !== null, $this->storage->exists($manifestPath));
7878

7979
$this->sendChunk($id, '%PDF', 0, 4)->assertNoContent();
8080
$requests = $this->azureRequests();
8181
$headers = array_change_key_case($requests[1]['headers']);
82-
$this->assertSame($expectedContentType ?? 'application/octet-stream', $headers['x-ms-blob-content-type'] ?? null);
82+
$this->assertSame($expectedFileContentType ?? 'application/octet-stream', $headers['x-ms-blob-content-type'] ?? null);
8383
$this->assertSame([], $this->storage->allFiles(config('filepond.chunks_path')));
8484
}
8585

0 commit comments

Comments
 (0)