/// <summary> /// Get a picture local path /// </summary> /// <param name="picture">Picture instance</param> /// <param name="targetSize">The target picture size (longest side)</param> /// <param name="showDefaultPicture">A value indicating whether the default picture is shown</param> /// <returns></returns> public virtual string GetThumbLocalPath(Picture picture, int targetSize = 0, bool showDefaultPicture = true) { var url = GetPictureUrl(ref picture, targetSize, showDefaultPicture); if (string.IsNullOrEmpty(url)) { return(string.Empty); } return(GetThumbLocalPath(_fileProvider.GetFileName(url))); }
public virtual ActionResult <Download> Post() { var httpPostedFile = Request.Form.Files.FirstOrDefault(); if (httpPostedFile == null) { return(NotFound()); } var fileBinary = _downloadService.GetDownloadBits(httpPostedFile); var qqFileNameParameter = "qqfilename"; var fileName = httpPostedFile.FileName; if (string.IsNullOrEmpty(fileName) && Request.Form.ContainsKey(qqFileNameParameter)) { fileName = Request.Form[qqFileNameParameter].ToString(); } //remove path (passed in IE) fileName = _fileProvider.GetFileName(fileName); var contentType = httpPostedFile.ContentType; var fileExtension = _fileProvider.GetFileExtension(fileName); if (!string.IsNullOrEmpty(fileExtension)) { fileExtension = fileExtension.ToLowerInvariant(); } var download = new Download { DownloadGuid = Guid.NewGuid(), UseDownloadUrl = false, DownloadUrl = string.Empty, DownloadBinary = fileBinary, ContentType = contentType, //we store filename without extension for downloads Filename = _fileProvider.GetFileNameWithoutExtension(fileName), Extension = fileExtension, IsNew = true }; try { _downloadService.InsertDownload(download); //when returning JSON the mime-type must be set to text/plain //otherwise some browsers will pop-up a "Save As" dialog. return(download); } catch (Exception exc) { _logger.Error(exc.Message, exc); return(BadRequest()); } }