/** * Move a file between sources. * * @param BaseAssetSourceType $originatingSource * @param BaseAssetSourceType $targetSource * @param AssetFileModel $file * @param AssetFolderModel $folder * @param string $action * * @return AssetOperationResponseModel */ private function _moveFileBetweenSources(BaseAssetSourceType $originatingSource, BaseAssetSourceType $targetSource, AssetFileModel $file, AssetFolderModel $folder, $action = '') { $localCopy = $originatingSource->getLocalCopy($file); // File model will be updated in the process, but we need the old data in order to finalize the transfer. $oldFileModel = clone $file; $response = $targetSource->transferFileIntoSource($localCopy, $folder, $file, $action); if ($response->isSuccess()) { // Use the previous data to clean up craft()->assetTransforms->deleteAllTransformData($oldFileModel); $originatingSource->finalizeTransfer($oldFileModel); IOHelper::deleteFile($localCopy); } return $response; }