- ABP Framework version: v4.0
- UI type:MVC
- DB provider: EF Core
- **Tiered (MVC)
- Exception message and stack trace:
- Steps to reproduce the issue:"
I want to link to a file have uploaded to FileManager Module for example ,I have uploaded a file name "有害垃圾.docx" to FileManager
now In tui.Editor, I want insert a link when I click "Insert link" button
how to write the URL in the picture?
7 Answer(s)
-
0
Hi @zsanhong,
Files that uploaded with File Management module can't be downloaded directly by a link for now. We've added "token validation" for extra security.
First, the UI makes a request to the backend application to take token, that token will be used for download, Example:
File name: myfile.zip UI makes a request -> // api/file-management/get-token Token = 12345 UI opens a new tab with the url -> api/file-management/[MY-FILE-ID]?token=12345 Then the download process will start.
Tokens become expired when they used once. So, for each download request, you need to consume new token.
So, how you can achieve your request, let me show you one example.
You may create unique tokens for each dowload request by overriding
DownloadAsync
method ofFileDescriptorController
controller:Note that, you need to secure your api yourself.
[HttpGet] [Route("download/{id}")] [AllowAnonymous] public virtual async Task<IRemoteStreamContent> DownloadAsync(Guid id, string token) { var fileDescriptor = await FileDescriptorAppService.GetAsync(id); // add this if(string.IsNullOrWhiteSpace(token)) { token = await FileDescriptorAppService.GetDownloadTokenAsync(id); } Response.Headers.Add("Content-Disposition", $"attachment;filename=\"{fileDescriptor.Name}\""); Response.Headers.Add("Accept-Ranges", "bytes"); Response.ContentType = fileDescriptor.MimeType; return await FileDescriptorAppService.DownloadAsync(id, token); }
-
0
thank you @cotur. for now, I can't get the Id of the file have uploaded to FileManager Module directly, So I want to add a CopyUrl method to achieve my request. thanks.
-
0
hi @cotur, how to overriding DownloadAsync method of FileDescriptorController controller? I don't want to change the source code of FileManager Module.
-
0
Here is the full documentation for it.
https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services
-
0
thanks, another question. how to upload file size more than 28M? I can't upload file more than 28M in FileManagement Module
-
0
Hi,
There is no any option about file sizes in ABP Framework or related modules.
You may research for online. ABP Framework and File Management module use the default settings of ASP.NET.
-
0
This question has been automatically marked as stale because it has not had recent activity.