This article is a mirror article of machine translation, please click here to jump to the original article.

View: 45980|Reply: 6

[Source] Java oss Alibaba Cloud upload file settings download file name

[Copy link]
Posted on 7/26/2019 3:33:21 PM | | | |
Today, I encountered a problem when using OSS Alibaba Cloud to complete the file upload operation, after the file is uploaded to the Alibaba Cloud server, a URL path will be returned, but the file name encrypted by MD5 is downloaded through the URL path

After checking the SDK documentation of Alibaba Cloud, you can set the download file name by setting the request header:

The specific code is as follows:

Be sure to look carefully!!!!!!!!

==============================================
The core of solving the problem:
//获取原文件名
String filename = file.getOriginalName();
Set the request header information when uploading the file, so that the upload returns the URL path of the file storage, and we can get the source file name instead of the encrypted random code by downloading it directly through the URL path.
meta.setContentDisposition("attachment; filename=\""+filename+"\"");

==============================================







Previous:php header() function to set the page cache
Next:Win10 can't use emulators
 Landlord| Posted on 7/26/2019 3:46:30 PM |
The .NET test is shown below:


Code:



Posted on 11/27/2019 11:24:49 AM |
 Landlord| Posted on 4/7/2021 1:16:00 PM |
Standard output download name

content-disposition: attachment; filename=1111.txt; filename*=UTF-8''1111.txt
content-length: 4404
content-type: application/octet-stream
 Landlord| Posted on 6/7/2021 9:19:32 AM |
 Landlord| Posted on 6/9/2021 5:52:08 PM |
asp.net core tries to get the content-type

 Landlord| Posted on 11/10/2025 1:22:47 PM |
ASP.NET Core (33) File Output Download (Chinese file name)
https://www.itsvse.com/thread-11131-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com