Ejemplo n.º 1
0
 public function putFile(array &$file, &$continue)
 {
     $this->init();
     try {
         $this->blobProxy->createBlockBlob($this->container, $file['id'], $file['data']);
     } catch (ServiceException $ex) {
         $continue = false;
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Upload a file.
  *
  * @param string           $path     Path
  * @param string|resource  $contents Either a string or a stream.
  * @param Config           $config   Config
  *
  * @return array
  */
 protected function upload($path, $contents, Config $config)
 {
     $path = $this->applyPathPrefix($path);
     /** @var CopyBlobResult $result */
     $result = $this->client->createBlockBlob($this->container, $path, $contents, $this->getOptionsFromConfig($config));
     return $this->normalize($path, $result->getLastModified()->format('U'), $contents);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function getMetadata($key)
 {
     $this->init();
     try {
         $properties = $this->blobProxy->getBlobProperties($this->containerName, $key);
         return $properties->getMetadata();
     } catch (ServiceException $e) {
         $errorCode = $this->getErrorCodeFromServiceException($e);
         throw new \RuntimeException(sprintf('Failed to get metadata for blob "%s" in container "%s": %s (%s).', $key, $this->containerName, $e->getErrorText(), $errorCode), $e->getCode());
     }
 }
Ejemplo n.º 4
0
 /**
  * Upload a file.
  *
  * @param string $path
  * @param mixed  $content Either a string or a stream.
  * @param Config $config
  *
  * @return array
  */
 protected function upload($path, $contents, Config $config)
 {
     /** @var CopyBlobResult $result */
     $result = $this->client->createBlockBlob($this->container, $path, $contents);
     return $this->normalize($path, $result->getLastModified()->format('U'), $contents);
 }
 /**
  * @param \Gaufrette\Adapter\AzureBlobStorage\BlobProxyFactoryInterface $blobProxyFactory
  * @param \WindowsAzure\Blob\Internal\IBlob                             $blobProxy
  */
 public function it_should_not_mask_exception_when_write($blobProxyFactory, $blobProxy)
 {
     $blobProxy->createBlockBlob('containerName', 'filename', 'some content', \Mockery::type('\\WindowsAzure\\Blob\\Models\\CreateBlobOptions'))->willThrow(new \RuntimeException('write'));
     $blobProxyFactory->create()->shouldBeCalled()->willReturn($blobProxy);
     $this->shouldThrow(new \RuntimeException('write'))->duringWrite('filename', 'some content');
 }