Loading src/StreamWrapper/AzBlobFsStream.php +42 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use GuzzleHttp\Psr7\Stream; use GuzzleHttp\Psr7\StreamDecoratorTrait; use MicrosoftAzure\Storage\Blob\Models\Block; use MicrosoftAzure\Storage\Blob\Models\BlockList; use MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions; use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions; use MicrosoftAzure\Storage\Common\Exceptions\ServiceException; use Psr\Http\Message\StreamInterface; Loading Loading @@ -385,9 +386,49 @@ class AzBlobFsStream extends AzBlobFsStreamWrapper implements StreamWrapperInter $blocksList = BlockList::create($blocks); $blob_name = $this->streamWrapperManager->getTarget($this->uri); $blob_parts = pathinfo($blob_name); $blob_extension = $blob_parts['extension'] ?? NULL; // @todo Have a valid file extensions config? switch ($blob_extension) { case 'doc': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/msword'); break; case 'docx': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/vnd.openxmlformats-officedocument.wordprocessingml.document'); break; case 'gif': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/gif'); break; case 'jpeg': case 'jpg': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/jpeg'); break; case 'pdf': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/pdf'); break; case 'png': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/png'); break; case 'svg': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/svg+xml'); break; case 'txt': $options = new CommitBlobBlocksOptions(); $options->setContentType('text/plain'); break; } $this->client->createBlobBlock($this->container, $blob_name, $block_id, $this->stream); $this->client->commitBlobBlocks($this->container, $blob_name, $blocksList); $this->client->commitBlobBlocks($this->container, $blob_name, $blocksList, $options ?? NULL); $this->stream = ''; $this->iterator = FALSE; Loading Loading
src/StreamWrapper/AzBlobFsStream.php +42 −1 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ use GuzzleHttp\Psr7\Stream; use GuzzleHttp\Psr7\StreamDecoratorTrait; use MicrosoftAzure\Storage\Blob\Models\Block; use MicrosoftAzure\Storage\Blob\Models\BlockList; use MicrosoftAzure\Storage\Blob\Models\CommitBlobBlocksOptions; use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions; use MicrosoftAzure\Storage\Common\Exceptions\ServiceException; use Psr\Http\Message\StreamInterface; Loading Loading @@ -385,9 +386,49 @@ class AzBlobFsStream extends AzBlobFsStreamWrapper implements StreamWrapperInter $blocksList = BlockList::create($blocks); $blob_name = $this->streamWrapperManager->getTarget($this->uri); $blob_parts = pathinfo($blob_name); $blob_extension = $blob_parts['extension'] ?? NULL; // @todo Have a valid file extensions config? switch ($blob_extension) { case 'doc': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/msword'); break; case 'docx': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/vnd.openxmlformats-officedocument.wordprocessingml.document'); break; case 'gif': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/gif'); break; case 'jpeg': case 'jpg': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/jpeg'); break; case 'pdf': $options = new CommitBlobBlocksOptions(); $options->setContentType('application/pdf'); break; case 'png': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/png'); break; case 'svg': $options = new CommitBlobBlocksOptions(); $options->setContentType('image/svg+xml'); break; case 'txt': $options = new CommitBlobBlocksOptions(); $options->setContentType('text/plain'); break; } $this->client->createBlobBlock($this->container, $blob_name, $block_id, $this->stream); $this->client->commitBlobBlocks($this->container, $blob_name, $blocksList); $this->client->commitBlobBlocks($this->container, $blob_name, $blocksList, $options ?? NULL); $this->stream = ''; $this->iterator = FALSE; Loading