public IActionResult Upload(IFormFile[] file, Guid?id) //Dropzone içerisinde tanımlı kelıme file { if (id.HasValue) { Post post = _postRepository.GetById(id.Value); if (post == null) { return(NotFound()); } if (file.Length > 0) { foreach (var item in file) { var result = _fileUpload.Upload(item); if (result.FileResult == Utility.FileResult.Succeded) { PostImage image = new PostImage { ImageUrl = result.FileUrl, PostId = id.Value }; _postImageRepository.Add(image); _postImageRepository.Save(); } } } } return(View()); }
public IActionResult Upload(IFormFile[] file, Guid?id) //bilinçli olarak file býrakýldý. dropzone içerinde tanýmlý kelime file!!!! { if (!id.HasValue) { Post post = _postRepository.GetById(id.Value); if (id == null) { return(NotFound()); } if (file.Length > 0) { foreach (var item in file) { var result = _fileUpload.Upload(item); if (result.FileResult == Utility.FileResult.Succeded) { PostImage image = new PostImage(); image.ImageURL = result.FileUrl; image.PostId = id.Value; } } } } return(View()); }
public async Task <IActionResult> Upload(IFormFile[] file, int estateId) //Defined word "file" in dropzone { if (estateId != 0) { var estate = await _estateService.FirstOrDefaultAsync(x => x.Id == estateId); if (estate == null) { return(NotFound()); } if (file.Length > 0) { foreach (var item in file) { var result = _fileUpload.Upload(item); if (result.FileResult == Utilities.FileResult.Succeded) { EstatePicture estatePicture = new EstatePicture(); estatePicture.ImageUrl = result.FileUrl; estatePicture.EstateId = estate.Id; estate.EstatePictures.Add(estatePicture); await _myLibraryProjectDbContext.SaveChangesAsync(); } } } } return(View()); }
public IActionResult Upload(IFormFile file) { var imgId = string.Empty; try { UploadeResponse objResult = _fileUploade.Upload(file); if (!objResult.Success) { return(StatusCode(500, new UploadeResponse { ImageID = imgId, Success = false, ErrorDescription = objResult.ErrorDescription })); } imgId = objResult.ImageID; } catch (Exception ex) { _logger.LogCritical($"Exception while uploading image.", ex); return(StatusCode(500, new UploadeResponse { ImageID = imgId, Success = false, ErrorDescription = ex.Message })); } return(Ok(new UploadeResponse { ImageID = imgId, Success = true })); }
public async Task <IActionResult> ImageUpload() { if (!Request.HasFormContentType) { return(BadRequest()); } var formFile = Request.Form.Files.ToList().FirstOrDefault(); string path = await _fileUpload.Upload(formFile); _userRepo.UpdateImage(_userInfo.UserId, path); await _uow.SaveAsync(); return(Ok()); }
private void Form_Project_Docs_UpLoad_Load(object sender, EventArgs e) { label_filename.Text = Uploadfilename; IFileUpload upload = new IFileUpload(LoginInfo.GetLoginId()); upload.EventFileUploadProgress += web_UploadProgressChanged; try { upload.Upload(Uploadfilename, md5, key); } catch (Exception) { throw; } }
public async Task <IActionResult> Create(Guid id, IFormFile file) { var path = await _fileUpload.Upload(file); var image = new MFile { Id = Guid.NewGuid(), Path = path, Ext = Path.GetExtension(file.FileName) }; await _context.Files.AddAsync(image); var book = await _context.Books.SingleAsync(it => it.Id == id); book.Cover = image; await _context.SaveChangesAsync(); return(RedirectToAction("Edit", "Book", new { id })); }
public void UploadText([FromBody] FileUploadModel model) { _fileUpload.Upload(model.FileName, model.Text); }