Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

用getObject 获取bufferr 下载文件 保存后不能打开 #102

Open
buxueke opened this issue Jun 6, 2023 · 0 comments
Open

用getObject 获取bufferr 下载文件 保存后不能打开 #102

buxueke opened this issue Jun 6, 2023 · 0 comments

Comments

@buxueke
Copy link

buxueke commented Jun 6, 2023

var config = {
credentials: {
ak: stsToken.accessKeyId, // 您的AK
sk: stsToken.secretAccessKey // 您的SK
},
sessionToken: stsToken.sessionToken,
endpoint: 'https://bj.bcebos.com' // 传入Bucket所在区域域名
}
const client = new baidubce.sdk.BosClient(config)
var response = await client.getObject(bucket, key)
var blob=new Blob([response.body], { type: 'application/pdf' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = name
a.click()
URL.revokeObjectURL(url)

下载后文件大小不对和原始文件不一样
有人知道为什么吗

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant