/**
  * {@inheritdoc}
  */
 public function upload($filePath, $mimeType, $size)
 {
     $fileHash = $this->factory->createFileHash($filePath);
     $chunks = array();
     $this->fileSplitter->split($filePath, function ($index, $data) use(&$chunks) {
         $chunk = $this->uploadChunk($data);
         $chunks[$index] = $this->chunkManager->downloadProxy($chunk->getHash());
         // unset chunk to save memory
         unset($chunk);
     });
     $file = new ChunkFile();
     $file->setHash($fileHash);
     $file->setSize($size);
     $file->setMimetype($mimeType);
     $file->setChunks($chunks);
     return $file;
 }
Exemplo n.º 2
0
 public function downloadProxy($hash)
 {
     return $this->factory->createProxy(ChunkInterface::class, function () use($hash) {
         return $this->download($hash);
     });
 }
 /**
  * {@inheritdoc}
  */
 public function createHash(UserInterface $user, $name)
 {
     return $this->factory->createHash(sprintf('%s@%s/%s', $user->getUsername(), $this->hostName, $name));
 }
Exemplo n.º 4
0
 public function fetchProxy($hash, $className)
 {
     return $this->factory->createProxy($className, function () use($hash, $className) {
         return $this->fetch($hash, $className);
     });
 }