Use antd to upload files to oss, if you set the http header?

because files uploaded to oss, downloading files in pdf format will be opened by default. In order to avoid this problem, you need to set the Content-Disposition of the http header to attachment;, so ask the god how to set the http header information before uploading.

Aug.06,2021

antd is not very familiar. It should be a function such as beforeupload (file), which is executed before upload. To change the http header, you can replace the encapsulated file as the file, obtained by the function in this function. Then the header of the file will be changed to be downloaded directly by oss-> Content-Type: application/octet-stream


did you see the answer given to you yesterday?
set the http header in oss


you can learn from this:
import {Upload, message, Button, Icon} from 'antd';

const props = {
name: 'file',
action:' / / jsonplaceholder.typicode.com/posts/',
headers: {

authorization: 'authorization-text',

},
onChange (info) {

if (info.file.status !== 'uploading') {
  console.log(info.file, info.fileList);
}
if (info.file.status === 'done') {
  message.success(`${info.file.name} file uploaded successfully`);
} else if (info.file.status === 'error') {
  message.error(`${info.file.name} file upload failed.`);
}

},
};

ReactDOM.render (
< Upload {.props} >

<Button>
  <Icon type="upload" /> Click to Upload
</Button>

< / Upload >,
mountNode);

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea865f-1ed6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea865f-1ed6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?