Skip to content

Commit

Permalink
Set mime type and caching headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Dec 10, 2011
1 parent dc8849a commit a45f466
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions class.azureAccessDriver.php
Expand Up @@ -71,7 +71,7 @@ public function initRepository()
$this->https_cdn_base = $this->repository->getOption('AZURE_CDN_HTTPS');

// Register the Azure stream wrapper
$this->storage->registerStreamWrapper();
//$this->storage->registerStreamWrapper();
//$this->wrapperClassName = 'azureAccessWrapper';
}

Expand Down Expand Up @@ -403,6 +403,9 @@ private function upload($httpVars, $fileVars, $dir, $selection)
if (!empty($pathinfo->path))
$pathinfo->path .= '/';

// fileinfo is used to get MIME type of uploaded file
$fileinfo = new finfo(FILEINFO_MIME_TYPE);

foreach ($fileVars as $boxName => $boxData)
{
// Skip data that isn't files we want
Expand All @@ -420,7 +423,12 @@ private function upload($httpVars, $fileVars, $dir, $selection)
$filename = AJXP_Utils::sanitize(SystemTextEncoding::magicDequote($boxData['name']), AJXP_SANITIZE_HTML_STRICT);

// Save the file into blob storage
$this->storage->putBlob($pathinfo->container, $pathinfo->path . $filename, $boxData['tmp_name']);
$this->storage->putBlob($pathinfo->container, $pathinfo->path . $filename, $boxData['tmp_name'], array(), null, array(
'Content-Type' => $fileinfo->file($boxData['tmp_name']),
'Cache-Control' => 'public, max-age=2592000',
));

AJXP_Logger::logAction('Upload File', array('file' => SystemTextEncoding::fromUTF8($dir) . '/' . $filename));
}
}

Expand Down

0 comments on commit a45f466

Please sign in to comment.