/// <summary> /// 下载指定路径的文件。 /// </summary> /// <param name="path">指定要下载的文件的相对路径或绝对路径(绝对路径以/斜杠打头)。</param> public HttpResponseMessage Get(string path) { if (string.IsNullOrEmpty(path)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return(_accessor.Read(path)); }
public HttpResponseMessage Download(string id) { var file = base.Get(id) as File; if (file == null || string.IsNullOrWhiteSpace(file.Path)) { return(null); } var response = _accessor.Read(file.Path); if (response != null && response.Content != null && !string.IsNullOrWhiteSpace(file.Type)) { response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(file.Type); } return(response); }