Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

downloading a large file 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;

    }
Source by support.aspnetzero.com #
 
PREVIOUS NEXT
Tagged: #downloading #large #file #asp #boilerplate
ADD COMMENT
Topic
Name
1+7 =