Uploader/Uploader.php
public function upload(UploadableInterface $uploadable)
    {
        if ($uploadable->hasPath()) {
            $targetKey = sprintf('%s://%s', $this->targetFileSystem, $uploadable->getPath());

            // By file
            if ($uploadable->hasFile()) {
                $file = $uploadable->getFile();

                if (false === $stream = fopen($file->getRealPath(), 'r+')) {
                    throw new UploadException(sprintf('Failed to open file "%s".', $file->getRealPath()));
                }

                if (!$this->mountManager->writeStream($targetKey, $stream)) {
                    throw new UploadException(sprintf('Failed to copy file from "%s" to "%s".', $file->getRealPath(), $targetKey));
                }

                fclose($stream);
                unlink($file->getRealPath());

                $uploadable->setFile(null);

            // By key
            } elseif ($uploadable->hasKey()) {
                $sourceKey = $uploadable->getKey();

                if (!$this->moveKey($sourceKey, $targetKey)) {
                    throw new UploadException(sprintf('Failed to copy file from "%s" to "%s".', $sourceKey, $targetKey));
                }

                $uploadable->setKey(null);

            // Rename
            } elseif ($uploadable->hasOldPath()) {
                $fs = $this->getFilesystem();

                if (!$fs->rename($uploadable->getOldPath(), $uploadable->getPath())) {
                    throw new UploadException(sprintf('Failed to rename file from "%s" to "%s".', $uploadable->getOldPath(), $uploadable->getPath()));
                }

                $this->cleanUp($uploadable->getOldPath());
                $uploadable->setOldPath(null);
            }
        }
    }
public function upload(UploadableInterface $uploadable)
    {
        if ($uploadable->hasPath()) {
            $targetKey = sprintf('%s://%s', $this->targetFileSystem, $uploadable->getPath());

            // By file
            if ($uploadable->hasFile()) {
                $file = $uploadable->getFile();

                if (false === $stream = fopen($file->getRealPath(), 'r+')) {
                    throw new UploadException(sprintf('Failed to open file "%s".', $file->getRealPath()));
                }

                if (!$this->mountManager->writeStream($targetKey, $stream)) {
                    throw new UploadException(sprintf('Failed to copy file from "%s" to "%s".', $file->getRealPath(), $targetKey));
                }

                fclose($stream);
                unlink($file->getRealPath());

                $uploadable->setFile(null);

            // By key
            } elseif ($uploadable->hasKey()) {
                $sourceKey = $uploadable->getKey();

                if (!$this->moveKey($sourceKey, $targetKey)) {
                    throw new UploadException(sprintf('Failed to copy file from "%s" to "%s".', $sourceKey, $targetKey));
                }

                $uploadable->setKey(null);

            // Rename
            } elseif ($uploadable->hasOldPath()) {
                $fs = $this->getFilesystem();

                if (!$fs->rename($uploadable->getOldPath(), $uploadable->getPath())) {
                    throw new UploadException(sprintf('Failed to rename file from "%s" to "%s".', $uploadable->getOldPath(), $uploadable->getPath()));
                }

                $this->cleanUp($uploadable->getOldPath());
                $uploadable->setOldPath(null);
            }
        }
    }
{@inheritdoc}