private static async Task <UploadOperation> CreateUploadOperationForCreateImage( IStorageFile file, string token, BackgroundUploader uploader) { const string boundary = "imgboundary"; List <BackgroundTransferContentPart> parts = new List <BackgroundTransferContentPart>(); BackgroundTransferContentPart metadataPart = new BackgroundTransferContentPart("token"); metadataPart.SetText(token); //metadataPart.SetText("iamatoken"); parts.Add(metadataPart); BackgroundTransferContentPart imagePart = new BackgroundTransferContentPart("photo", file.Name); imagePart.SetFile(file); imagePart.SetHeader("Content-Type", file.ContentType); parts.Add(imagePart); return (await uploader.CreateUploadAsync( new Uri(HttpFotosSapoPtUploadpostHtmlUri), parts, "form-data", boundary)); }
private static async Task<UploadOperation> CreateUploadOperationForCreateVideo( IStorageFile file, string token, BackgroundUploader uploader) { const string boundary = "videoboundary"; List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>(); BackgroundTransferContentPart metadataPart = new BackgroundTransferContentPart("token"); metadataPart.SetText(token); //metadataPart.SetText("iamatoken"); parts.Add(metadataPart); BackgroundTransferContentPart videoPart = new BackgroundTransferContentPart("content_file", file.Name); videoPart.SetFile(file); videoPart.SetHeader("Content-Type", file.ContentType); parts.Add(videoPart); return await uploader.CreateUploadAsync( new Uri(AddVideoPostUri), parts, "form-data", boundary); }
private static async Task <UploadOperation> CreateUploadOperationForCreateVideo( IStorageFile file, string token, BackgroundUploader uploader) { const string boundary = "videoboundary"; List <BackgroundTransferContentPart> parts = new List <BackgroundTransferContentPart>(); BackgroundTransferContentPart metadataPart = new BackgroundTransferContentPart("token"); metadataPart.SetText(token); //metadataPart.SetText("iamatoken"); parts.Add(metadataPart); BackgroundTransferContentPart videoPart = new BackgroundTransferContentPart("content_file", file.Name); videoPart.SetFile(file); videoPart.SetHeader("Content-Type", file.ContentType); parts.Add(videoPart); return (await uploader.CreateUploadAsync( new Uri(AddVideoPostUri), parts, "form-data", boundary)); }
private BackgroundTransferContentPart CreateContentPart(IUpload upload, string fieldName) { var part = new BackgroundTransferContentPart(fieldName, $"{upload.Uploadable.Name}{upload.Uploadable.Extension}"); part.SetHeader("Content-Type", upload.Uploadable.Source.GetContentType()); part.SetFile(upload.Uploadable.Source.GetFile()); return(part); }
BackgroundTransferContentPart GetTextPart(string key, string value) { // namesh mishe KEY va textesh mishe VALUE BackgroundTransferContentPart part = new BackgroundTransferContentPart(key); // chon typeshon text hast va utf-8 bayad content typeshon ro set konim be in part.SetHeader("Content-Type", "text/plain; charset=utf-8"); part.SetText(value); // sare ham ye chize in shekli mogheye upload ijad mishe: //Content-Type: text/plain; charset=utf-8 //Content-Disposition: form-data; name="_uuid" // //86665e74-5514-8236-basu-15aef8ceb0d6 return(part); }
private static async Task<UploadOperation> CreateUploadOperationForCreateImage( IStorageFile file, string token, BackgroundUploader uploader) { const string boundary = "imgboundary"; List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>(); BackgroundTransferContentPart metadataPart = new BackgroundTransferContentPart("token"); metadataPart.SetText(token); //metadataPart.SetText("iamatoken"); parts.Add(metadataPart); BackgroundTransferContentPart imagePart = new BackgroundTransferContentPart("photo", file.Name); imagePart.SetFile(file); imagePart.SetHeader("Content-Type", file.ContentType); parts.Add(imagePart); return await uploader.CreateUploadAsync( new Uri(HttpFotosSapoPtUploadpostHtmlUri), parts, "form-data", boundary); }