Download de um grande arquivo ASP Boilerplate (ABP)
//**Angular **
export class FileDownloadService {
downloadTempFile(file: FileDto) {
const url = AppConsts.remoteServiceBaseUrl + '/File/DownloadTempFile?fileType=' + file.fileType + '&fileToken=' + file.fileToken + '&fileName=' + file.fileName;
location.href = url; //TODO: This causes reloading of same page in Firefox
}
downloadFiles(fileName: string, fileToken: string) {
const url = AppConsts.remoteServiceBaseUrl + '/FileManager/GetFile?fileName=' + fileName + '&fileToken=' + fileToken;
location.href = url; //TODO: This causes reloading of same page in Firefox
}
// Core
public async Task<FileStreamResult> GetFile(string fileName, string fileToken)
{
Stream stream = null;
string filePath = Path.Combine(_env.WebRootPath, $"Common{Path.DirectorySeparatorChar}", $"Files{Path.DirectorySeparatorChar}", fileToken);
stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var fileStreaResult = new FileStreamResult(stream, "application/pdf");
fileStreaResult.FileDownloadName = fileName;
return fileStreaResult;
}
Muhammad Hassan