MINOR Checking for success of file upload before trying to add metadata in AssetAdmin->doUpload() (AIR-37)

This commit is contained in:
Ingo Schommer 2011-09-01 14:49:23 +02:00
parent 6b9b0ef161
commit d81f882b4f

View File

@ -255,17 +255,17 @@ JS
// move file to given folder // move file to given folder
if($valid) { if($valid) {
$newFile = $folder->addUploadToFolder($tmpFile); if($newFile = $folder->addUploadToFolder($tmpFile)) {
if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) {
if(self::$metadata_upload_enabled && isset($processedData[$filePostId])) { $fileObject = DataObject::get_by_id('File', $newFile);
$fileObject = DataObject::get_by_id('File', $newFile); $metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet());
$metadataForm = new Form($this, 'MetadataForm', $fileObject->uploadMetadataFields(), new FieldSet()); $metadataForm->loadDataFrom($processedData[$filePostId]);
$metadataForm->loadDataFrom($processedData[$filePostId]); $metadataForm->saveInto($fileObject);
$metadataForm->saveInto($fileObject); $fileObject->write();
$fileObject->write(); }
$newFiles[] = $newFile;
} }
$newFiles[] = $newFile;
} }
} }
} }