Attachment/AttachmentHandler.php
protected function copyToStorage(File $file, FileKey $fileKey)
    {
        $storage = $this->getStorage($fileKey->getStorageName());
        $storagePath = $this->getStoragePath($storage, $fileKey);
        
        $filesystem = $storage->getFilesystem();
        if (!$filesystem->has($storagePath))
        {
            $size = $file->getSize();
            $writtenSize = $filesystem->write($storagePath, file_get_contents($file->getRealPath()));
            
            if ($writtenSize != $size)
            {
                throw new CouldNotWriteToStorageException('Error copying file ' . $file->getRealPath() . ' to storage');
            }
        }
    }
protected function copyToStorage(File $file, FileKey $fileKey)
    {
        $storage = $this->getStorage($fileKey->getStorageName());
        $storagePath = $this->getStoragePath($storage, $fileKey);
        
        $filesystem = $storage->getFilesystem();
        if (!$filesystem->has($storagePath))
        {
            $size = $file->getSize();
            $writtenSize = $filesystem->write($storagePath, file_get_contents($file->getRealPath()));
            
            if ($writtenSize != $size)
            {
                throw new CouldNotWriteToStorageException('Error copying file ' . $file->getRealPath() . ' to storage');
            }
        }
    }
protected function copyToStorage ( File $ file , FileKey $ fileKey ) { $ storage = $ this -> getStorage ( $ fileKey -> getStorageName ( ) ) ; $ storagePath = $ this -> getStoragePath ( $ storage , $ fileKey ) ; $ filesystem = $ storage -> getFilesystem ( ) ; if ( ! $ filesystem -> has ( $ storagePath ) ) { $ size = $ file -> getSize ( ) ; $ writtenSize = $ filesystem -> write ( $ storagePath , file_get_contents ( $ file -> getRealPath ( ) ) ) ; if ( $ writtenSize != $ size ) { throw new CouldNotWriteToStorageException ( 'Error copying file ' . $ file -> getRealPath ( ) . ' to storage' ) ; } } }
Move the file to the storage as defined in the given file key.

@param File $file
@param string $fileKey
Move the file to the storage as defined in the given file key .