We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题描述: 比如在 https://github.com/ 使用 ali-oss 进行文件上传,在上传之前会发起一个 get 方式的 https://github.com/ 请求,这个请求如何避免掉呢,无法避免的情况下,发起这个请求的原因是什么呢?
react hook如下:
import OSS from 'ali-oss'; import { useRef } from 'react'; import { getOSSTokenV2 } from '@/services'; const useOssClient = () => { // const [ossClient, setOssClient] = useState<OSS>(); const ossClient = useRef<OSS>(); //初始化oss client客户端 async function initOssClient() { const { data } = await getOSSTokenV2(); if (data) { const client = new OSS({ secure: true, // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。 region: data.region, // 从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。 accessKeyId: data.access_key_id, accessKeySecret: data.access_key_secret, // 从STS服务获取的安全令牌(SecurityToken)。 stsToken: data.security_token, refreshSTSToken: async () => { // 向您搭建的STS服务获取临时访问凭证。 const { data: refreshData } = await getOSSTokenV2(); if (refreshData) { return { accessKeyId: refreshData.access_key_id, accessKeySecret: refreshData.access_key_secret, stsToken: refreshData.security_token, }; } return { accessKeyId: '', accessKeySecret: '', stsToken: '', }; }, // 刷新临时访问凭证的时间间隔,单位为毫秒。 refreshSTSTokenInterval: 3000000, // 填写Bucket名称。 bucket: data.bucket, }); if (client) { ossClient.current = client; return client; } } } async function getClient() { if (ossClient.current) { return ossClient.current; } return await initOssClient(); } return { getClient }; }; export default useOssClient;
The text was updated successfully, but these errors were encountered:
我们使用您提供的代码片段进行复现,并没有发现您说的Get请求,麻烦您再看下您代码里的逻辑是否正确,或者提供更详细的代码,我们再看一下。
Sorry, something went wrong.
No branches or pull requests
问题描述:
比如在 https://github.com/ 使用 ali-oss 进行文件上传,在上传之前会发起一个 get 方式的 https://github.com/ 请求,这个请求如何避免掉呢,无法避免的情况下,发起这个请求的原因是什么呢?
react hook如下:
The text was updated successfully, but these errors were encountered: