Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add larger files #35

Merged
Merged
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
11 changes: 6 additions & 5 deletions Classes/Driver/StorageDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesOptions;
use MicrosoftAzure\Storage\Blob\Models\SetBlobPropertiesResult;
use MicrosoftAzure\Storage\Common\Internal\Utilities;
use Psr\Http\Message\StreamInterface;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Resource\Driver\AbstractHierarchicalFilesystemDriver;
Expand Down Expand Up @@ -338,7 +339,7 @@ public function addFile($localFilePath, $targetFolderIdentifier, $newFileName =
$options->setContentType($contentType);
$options->setCacheControl($this->cacheControl);

$this->createBlockBlob($fileIdentifier, file_get_contents($localFilePath), $options);
$this->createBlockBlob($fileIdentifier, fopen($localFilePath, 'rb'), $options);

if ($removeOriginal === true) {
@unlink($localFilePath);
Expand Down Expand Up @@ -1244,17 +1245,17 @@ protected function getBlob($fileIdentifier)

/**
* @param $name
* @param string $content
* @param string|resource|StreamInterface $content
* @param CreateBlockBlobOptions|null $options
* @return \MicrosoftAzure\Storage\Blob\Models\CopyBlobResult
*/
protected function createBlockBlob($name, $content = '', CreateBlockBlobOptions $options = null)
{
if (!is_string($content)) {
throw new \InvalidArgumentException('Content was not type of string');
if (!is_string($content) && !is_resource($content) && !($content instanceof StreamInterface)) {
throw new \InvalidArgumentException('Content was not a valid type');
}

if ($content === '') {
if (is_string($content) && $content === '') {
$content = chr(26);
}

Expand Down