public function upload(FileInterface $file, $name, $path = null)
 {
     $path = is_null($path) ? $name : sprintf('%s/%s', $path, $name);
     if ($file instanceof FlysystemFile) {
         if ($file->getFilesystem() == $this->filesystem) {
             $file->getFilesystem()->rename($file->getPath(), $path);
             return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
         }
     }
     $this->filesystem->put($name, file_get_contents($file));
     if ($file instanceof FlysystemFile) {
         $file->delete();
     } else {
         $filesystem = new LocalFilesystem();
         $filesystem->remove($file->getPathname());
     }
     return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
 }
 public function upload(FileInterface $file, $name, $path = null)
 {
     $path = is_null($path) ? $name : sprintf('%s/%s', $path, $name);
     if ($file instanceof FlysystemFile) {
         if ($file->getFilesystem() == $this->filesystem) {
             $file->getFilesystem()->rename($file->getPath(), $path);
             return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
         }
     }
     $stream = fopen($file->getPathname(), 'r+');
     $this->filesystem->putStream($name, $stream);
     if (is_resource($stream)) {
         fclose($stream);
     }
     if ($file instanceof FlysystemFile) {
         $file->delete();
     } else {
         $filesystem = new LocalFilesystem();
         $filesystem->remove($file->getPathname());
     }
     return new FlysystemFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
 }
 public function upload(FileInterface $file, $name, $path = null)
 {
     $path = is_null($path) ? $name : sprintf('%s/%s', $path, $name);
     if ($this->filesystem->getAdapter() instanceof MetadataSupporter) {
         $this->filesystem->getAdapter()->setMetadata($name, array('contentType' => $file->getMimeType()));
     }
     if ($file instanceof GaufretteFile) {
         if ($file->getFilesystem() == $this->filesystem) {
             $file->getFilesystem()->rename($file->getKey(), $path);
             return new GaufretteFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
         }
     }
     $this->ensureRemotePathExists($path);
     $dst = $this->filesystem->createStream($path);
     $this->openStream($dst, 'w');
     $this->stream($file, $dst);
     if ($file instanceof GaufretteFile) {
         $file->delete();
     } else {
         $filesystem = new LocalFilesystem();
         $filesystem->remove($file->getPathname());
     }
     return new GaufretteFile($this->filesystem->get($path), $this->filesystem, $this->streamWrapperPrefix);
 }