/// <summary> /// Perform scaling, cropping and flipping of an existing image in a single request. And upload updated image to Cloud /// Storage. /// </summary> public void UpdateImageAndUploadToStorage() { Console.WriteLine("Update parameters of an image and upload to cloud storage"); UploadSampleImageToCloud(); // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Update // for possible output formats var format = "pdf"; int? newWidth = 300; int? newHeight = 450; int? x = 10; int? y = 10; int? rectWidth = 200; int? rectHeight = 300; var rotateFlipMethod = "Rotate90FlipX"; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var getImageUpdateRequest = new UpdateImageRequest(SampleImageFileName, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, format, folder, storage); Console.WriteLine( $"Call UpdateImage with params: new width:{newWidth}, new height:{newHeight}, x:{x}, y:{y}, rect width:{rectWidth}, rectHeight:{rectHeight}, rotate/flip method:{rotateFlipMethod}, format:{format}"); using (var updatedImage = ImagingApi.UpdateImage(getImageUpdateRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
public async Task <IActionResult> Update([FromRoute] string id) { var request = new UpdateImageRequest(id); await _mediator.Send(request); return(NoContent()); }
public void UpdateImageTest(string formatExtension, params string[] additionalExportFormats) { string name = null; int? newWidth = 300; int? newHeight = 450; int? x = 10; int? y = 10; int? rectWidth = 200; int? rectHeight = 300; string rotateFlipMethod = "Rotate90FlipX"; string folder = TempFolder; string storage = this.TestStorage; List <string> formatsToExport = new List <string>(this.BasicExportFormats); foreach (string additionalExportFormat in additionalExportFormats) { if (!formatsToExport.Contains(additionalExportFormat)) { formatsToExport.Add(additionalExportFormat); } } foreach (StorageFile inputFile in BasicInputTestFiles) { if (inputFile.Name.EndsWith(formatExtension)) { name = inputFile.Name; } else { continue; } foreach (string format in formatsToExport) { this.TestGetRequest( "UpdateImageTest", $"Input image: {name}; Output format: {format ?? "null"}; New width: {newWidth}; New height: {newHeight}; Rotate/flip method: {rotateFlipMethod}; " + $"X: {x}; Y: {y}; Rect width: {rectWidth}; Rect height: {rectHeight}", name, delegate { var request = new UpdateImageRequest(name, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, format, folder, storage); return(ImagingApi.UpdateImage(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.AreEqual(rectHeight, resultProperties.Width); Assert.AreEqual(rectWidth, resultProperties.Height); }, folder, storage); } } }
/// <summary> /// 更新镜像信息 /// </summary> public UpdateImageResponse UpdateImage(UpdateImageRequest updateImageRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("image_id", updateImageRequest.ImageId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v2/cloudimages/{image_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateImageRequest); HttpResponseMessage response = DoHttpRequestSync("PATCH", request); return(JsonUtils.DeSerialize <UpdateImageResponse>(response)); }
public IActionResult UpdateImage([FromBody] UpdateImageRequest updateImageRequest) { var account = _accountService.Get(a => a.Id == updateImageRequest.Id, null); if (account != null) { account.Password = updateImageRequest.Image; _accountService.Update(account); return(StatusCode(200, new { message = "Update Success" })); } return(StatusCode(404, new { message = "Not found your id" })); }
/// <summary> /// Modifies an image. /// </summary> public ImagesResponse Update(UpdateImageRequest image, string image_id) { try { var request = new RestRequest("/images/{image_id}", Method.PUT) { RequestFormat = DataFormat.Json, JsonSerializer = new CustomSerializer() }; request.AddUrlSegment("image_id", image_id); request.AddBody(image); var result = restclient.Execute <ImagesResponse>(request); if (result.StatusCode != HttpStatusCode.OK) { throw new Exception(result.Content); } return(result.Data); } catch { throw; } }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateImageRequest request; try { request = new UpdateImageRequest { ImageId = ImageId, UpdateImageDetails = UpdateImageDetails, OpcRetryToken = OpcRetryToken, IfMatch = IfMatch }; response = client.UpdateImage(request).GetAwaiter().GetResult(); WriteOutput(response, response.Image); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
//update image private static void UpdateImage(ImsClient imsV2Client) { UpdateImageRequest updateImsInfoRequest = new UpdateImageRequest() { ImageId = "d70af0f0-515d-41d7-9c9f-bc4e2b233ee6", Body = new List <UpdateImageRequestBody>() { new UpdateImageRequestBody() { Op = UpdateImageRequestBody.OpEnum.REPLACE, Path = "/name", Value = "ims-test" } } }; try { var getImsListInfoResponse = imsV2Client.UpdateImage(updateImsInfoRequest); Console.WriteLine(getImsListInfoResponse.Id); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }