public async Task <IActionResult> ImageUploadBase64([FromBody] Base64UploadViewModel file) { if (file?.Base64?.Length == null) { return(BadRequest("Failed to upload file")); } var response = await _imageUploadLogic.Upload( Convert.FromBase64String(file.Base64), new Dictionary <string, string> { [ImageMetadataKey.Description] = file.Description, [ImageMetadataKey.Name] = file.Name } ); return(Ok(response)); }
public async Task <IActionResult> ImageUpload([FileMimeType("image/*")] IFormFile file, [FromQuery] string description) { var response = await _imageUploadLogic.Upload( await file.ToByteArray(), ImmutableDictionary <string, string> .Empty .Add(ImageMetadataKey.Description, description) ); return(Ok(response)); }
public async Task <IActionResult> ImageUpload([FromRoute] int id, [FromForm] IFormFile file) { var imageId = await _imageUploadLogic.Upload(await file.ToByteArray(), new Dictionary <string, string> { ["ProductType"] = ProductTypeEnum.Rug.ToString(), ["ProductId"] = id.ToString() }); await _rugLogic.AssignImage(id, imageId); return(Ok($"Successfully assigned image `{file.FileName}` to rug id: {id}")); }