-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
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
绑定cloudflare r2 图床异常 #545
Comments
我也是配置完cloudfareR2后报错了。 另外想问一下,默认提供的那个图床是长期能用的么?我就是怕以后不能用了导致图片都加载失效,如果能长期用,自己不折腾也OK |
默认的我也不用, |
cloudfareR2 确实有问题 |
谢谢反馈,已修复 @LurnD @myysophia @canopysgit |
抱歉看到的晚了,似乎是 aws 的 sdk 出了点问题 aws/aws-sdk-js-v3#6834 .我之前适配的时候版本是 async function r2Upload(file: File) {
const { accountId, accessKey, secretKey, bucket, path, domain } = JSON.parse(
localStorage.getItem(`r2Config`)!,
)
const dir = path ? `${path}/` : ``
const filename = dir + getDateFilename(file.name)
const client = new S3Client({ region: `auto`, endpoint: `https://${accountId}.r2.cloudflarestorage.com`, credentials: { accessKeyId: accessKey, secretAccessKey: secretKey } })
// new
const body = await file.arrayBuffer()
return new Promise<string>((resolve, reject) => {
const putObjectCommand = new PutObjectCommand({
Bucket: bucket,
Key: filename,
ContentType: file.type,
// Body: file,
Body: new Uint8Array(body),
})
client.send(putObjectCommand).then(() => {
resolve(`${domain}/${filename}`)
}).catch((err) => {
reject(err)
})
})
} PS: 修复用的预签名的方法,这也是一种实现。(我想少装一个库,就用了直接的方法)。 |
按照要求,填入各种 api 后,提示
错误
readableStream.getReader is not a function. (In'readableStream.getReader)',
'readableStream.getReader' is undefined)
请问什么原因。
The text was updated successfully, but these errors were encountered: