public function migrateToStorageFormat(PhabricatorFileStorageFormat $format) { if (!$this->getID() || !$this->getStorageHandle()) { throw new Exception(pht("You can not migrate a file which hasn't yet been saved.")); } $data = $this->loadFileData(); $params = array('name' => $this->getName()); $engine = $this->instantiateStorageEngine(); $old_handle = $this->getStorageHandle(); $properties = $format->newStorageProperties(); $this->setStorageFormat($format->getStorageFormatKey()); $this->setStorageProperties($properties); list($identifier, $new_handle) = $this->writeToEngine($engine, $data, $params); $this->setStorageHandle($new_handle); $this->save(); $this->deleteFileDataIfUnused($engine, $identifier, $old_handle); return $this; }