firebase / firebase/firebase-admin-node

SDK doesn't update filename in Content-Disposition metadata on File Rename

未关闭
#2,055 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: storage
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

Environment: `NextJS 12.3.0` + `React 18.2.0` Web Application (arbritrary for the sake of this issue)
Emulator Version: `11.5.0`

### Describe the problem

#### Steps to reproduce:
* Upload a file through the Firebase Storage console
* Rename the file (code sample below)
* Code Sample:
```
import * as firebase from 'firebase-admin'
const credential = firebase.credential.cert({
privateKey: process.env.FIREBASE_SERVER_PRIVATE_KEY.replace(/\n/g, '\n'),
clientEmail: process.env.FIREBASE_SERVER_CLIENT_EMAIL,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
})
firebase.apps.length === 0 && firebase.initializeApp({ credential })
export default async function handler(req, res) {
try {
const storage = firebase.storage().bucket('gs://fureyterminal-dev.appspot.com')
const filePath = 'public/demo_temp/SampleExcelFile.xlsx'
const newPath = 'public/demo_temp/RENAMEDExcelFile.xlsx'
const file = storage.file(filePath)
await file.rename(newPath)
res.status(200).send()
} catch (error) {
console.error(error)
res.status(500).send(error)
}
}
```

* Attempting to download this newly renamed file will display the old name.

+++

Also occurs via `gcloud storage mv gs://BUCKET_NAME/OLD_OBJECT_NAME gs://BUCKET_NAME/NEW_OBJECT_NAME"`

or renaming the file via the GCP console ===> Cloud Storage ===> Buckets

#### What Happened?

The culprit is that the `Content-Disposition` filename field is not updated when calling rename. You can see in the screenshot here (https://imgur.com/a/tyouzeS) that the filename is the old name of `tree.jpg`. Updating this value manually yields a downloaded file that has the correct name.

*This issue was submitted on behalf of a Firebase Storage user*

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。