}
if (keyTemplate == null) {
keyTemplate = "${pk}${ext}";
}
ERS3Attachment attachment = ERS3Attachment.createERS3Attachment(
editingContext, Boolean.FALSE, new NSTimestamp(), mimeType,
recommendedFileName, proxy,
Integer.valueOf((int) uploadedFile.length()), null);
if (delegate() != null) {
delegate().attachmentCreated(this, attachment);
}
try {
String key = ERAttachmentProcessor._parsePathTemplate(attachment,
keyTemplate, recommendedFileName);
attachment.setS3Location(bucket, key);
attachment.setConfigurationName(configurationName);
String s3Path = attachment.queryStringAuthGenerator().makeBareURL(
bucket, key);
attachment.setS3Path(s3Path);
attachment._setPendingUploadFile(uploadedFile, pendingDelete);
} catch (RuntimeException e) {
attachment.delete();
if (pendingDelete) {
uploadedFile.delete();
}
throw e;
}