Search
 
SCRIPT & CODE EXAMPLE
 

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;

    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: set data annotation in model c# 
Csharp :: poems 
Csharp :: Handle all AggregateExceptions when using Task.Whenall() async 
Csharp :: C# if...else if Statement 
Csharp :: Function delegate 
Csharp :: An error occurred while deserializing the property of class Truncation resulted in data loss. 
Csharp :: bitter foods examplews 
Csharp :: how to clear stackpanel wpf 
Csharp :: c# execute run control panel 
Csharp :: method declaration in c# 
Csharp :: tuples in c# 
Csharp :: six simple machines labeled 
Csharp :: cache.TryGetValue in MemoryCache c# .net 
Csharp :: crystal reports convert decimal to integer in formula 
Csharp :: c# stack 
Csharp :: split array into pieces of x length c# 
Csharp :: get image information using c# 
Csharp :: get position of gameobject unity 
Csharp :: c# mapper.map 
Csharp :: c# close all threads application exit 
Csharp :: populate combobox from array c# 
Csharp :: how to resize a panel unity 
Csharp :: how to backgrund c# red 
Csharp :: razor: show editable list 
Html :: html yen symbol 
Html :: how to open link in new tab 
Html :: no follow no index 
Html :: html input float type 
Html :: target blanc 
Html :: js import web3 cdn 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =