public UploadResponse Upload(UploadRequest request) { var tempFile = Path.GetTempFileName(); try { // write data to a temp file File.WriteAllBytes(tempFile, request.DataContent); // create the new document object, and put the remote file var args = new AttachedDocumentCreationArgs { MimeType = request.MimeType, FileExtension = request.FileExtension, LocalContentFilePath = tempFile }; var document = AttachedDocument.Create(args, AttachmentStore.GetClient()); PersistenceContext.Lock(document, DirtyState.New); PersistenceContext.SynchState(); var assembler = new AttachedDocumentAssembler(); return(new UploadResponse(assembler.CreateAttachedDocumentSummary(document))); } finally { File.Delete(tempFile); } }
public UploadResponse Upload(UploadRequest request) { var tempFile = Path.GetTempFileName(); try { // write data to a temp file File.WriteAllBytes(tempFile, request.DataContent); // create the new document object, and put the remote file var args = new AttachedDocumentCreationArgs { MimeType = request.MimeType, FileExtension = request.FileExtension, LocalContentFilePath = tempFile }; var document = AttachedDocument.Create(args, AttachmentStore.GetClient()); PersistenceContext.Lock(document, DirtyState.New); PersistenceContext.SynchState(); var assembler = new AttachedDocumentAssembler(); return new UploadResponse(assembler.CreateAttachedDocumentSummary(document)); } finally { File.Delete(tempFile); } }