public CreateAttachmentFromForm(CallContext callContext, HttpRequest request) : base(callContext) { HttpPostedFile httpPostedFile = request.Files[0]; string fileName = Path.GetFileName(httpPostedFile.FileName); this.translatedRequest = CreateAttachmentHelper.CreateAttachmentRequest(new ItemId(request.Form["parentItemId"], request.Form["parentChangeKey"]), fileName, httpPostedFile.ContentLength, httpPostedFile.ContentType, CreateAttachmentHelper.GetContentBytes(httpPostedFile.InputStream), bool.Parse(request.Form["isInline"]), request.Form["cancellationId"]); this.fileSize = httpPostedFile.ContentLength; this.contentType = httpPostedFile.ContentType; }
private CreateAttachmentRequest CreateImageAttachmentRequest(byte[] attachmentData) { CreateAttachmentRequest createAttachmentRequest = null; if (attachmentData != null) { string fileName = "BingMap"; string contentType = "image/jpeg"; createAttachmentRequest = CreateAttachmentHelper.CreateAttachmentRequest(this.request.ParentItemId, fileName, attachmentData.Length, contentType, attachmentData, true, null); } if (createAttachmentRequest == null) { throw new OwaException("CreateAttachmentRequestError"); } return(createAttachmentRequest); }