Skip to content

Commit

Permalink
added MimeTypeGuesser to set mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Magalhães committed Jul 5, 2013
1 parent 1ede611 commit 29cb733
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Blob/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

use WindowsAzure\Blob\BlobRestProxy;
use WindowsAzure\Blob\Models\ListContainersOptions;
use WindowsAzure\Blob\Models\CreateBlobOptions;
use WindowsAzure\Common\ServiceException;
use Exception;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;

/**
* Stream Wrapper implementation for Windows Azure Blob Storage
Expand Down Expand Up @@ -223,12 +225,17 @@ public function stream_close()
);
}

$mimeTypeGuesser = MimeTypeGuesser::getInstance();
$createBlobOptions = new CreateBlobOptions();
$createBlobOptions->setBlobContentType($mimeTypeGuesser->guess($this->temporaryFileName));

// Upload the file
try {
$result = $this->getStorageClient($this->fileName)->createBlockBlob(
$this->getContainerName($this->fileName),
$this->getFileName($this->fileName),
fopen($this->temporaryFileName, "r")
fopen($this->temporaryFileName, "r"),
$createBlobOptions
);
} catch (Exception $ex) {
$this->cleanup();
Expand Down

0 comments on commit 29cb733

Please sign in to comment.