why I can't download file in my AppService layer in abp?
See original GitHub issue[HttpGet]
[DontWrapResult]
public async Task DownloadCertificateFile(string companyDLRef)
{
var certificatePath = await SettingManager.GetSettingValueAsync(SettingKeyConstants.ExternalServices.Support.CertificatePath);
var certificateFolder = HostingEnvironmentAccessor.MapPath(certificatePath);
if (string.IsNullOrEmpty(companyDLRef) == false)
{
var allowedExtensions = new[] { ".jpeg", ".jpg", ".png", ".pdf" };
var files = Directory
.GetFiles(certificateFolder, companyDLRef + "*")
.Where(file => allowedExtensions.Any(file.ToLower().EndsWith))
.ToList();
if (files.Any())
{
var file = files.First();
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
var fileStream = new FileStream(file, FileMode.Open);
response.Content = new StreamContent(fileStream);
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = Path.GetFileName(file);
response.Content.Headers.ContentType = HasPdfExtension(file)? new MediaTypeHeaderValue("application/pdf") : new MediaTypeHeaderValue("image/png");
return response;
}
}
return new HttpResponseMessage();
}
Result is a json data:
{
"version": {
"major": 1,
"minor": 1,
"build": -1,
"revision": -1,
"majorRevision": -1,
"minorRevision": -1
},
"content": {
"headers": [
{
"key": "Content-Disposition",
"value": [
"attachment; filename=220006.jpg"
]
},
{
"key": "Content-Type",
"value": [
"image/png"
]
}
]
},
"statusCode": 200,
"reasonPhrase": "OK",
"headers": [],
"requestMessage": null,
"isSuccessStatusCode": true
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to download large file #1528 | Support Center
Another issue I found when trying Abp version 4.3.2, the downloaded file size is 0kb when downloading the large file (around ~500mb and ......
Read more >File Upload/Download with BLOB Storage System in ASP.NET ...
This step-by-step article describes how to upload a file to a Web server and also download by client with using ASP.NET Core &...
Read more >File Upload/Download with BLOB Storage System in ASP. ...
This step-by-step article describes how to upload a file to a Web server and also download by client with using ASP.NET Core &...
Read more >Angular 6 Downloading file from rest api - typescript
In My service I have: public getPDF(): Observable<Blob> { //const options = { responseType: 'blob' }; there is no use of this let...
Read more >ABP Framework — Web Application Development Tutorial ...
This video is based on this tutorial: https://docs. abp.io/en/ abp /latest/Tutorials/Part-1?UI=MVC&DB=EF 00:00 Introduction 01:07 Creating the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Return
Task<FileResult>
orTask<ActionResult>
from your method.Then create a controller in your web layer and internally use the app layer.