firebase / firebase/firebase-tools

Allow emulator writeable `publicUrl` with `PUT`, like a writeable `getSignedURL`

Open
#4,201 10 comments 7 reactions 1 assignee Assigned to @abhis3 View on GitHub
emulator-suite emulators: storage help-wanted type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

We use signed URLs to create writeable destinations for things like caching and intermediary steps. We would like to run this functionality in isolation so we can test it in CI and develop locally (and specifically without service account credentials). This does not seem to currently be possible with the Firebase Emulator.

We use the live production API to produce a `PUT` URL like this:

```ts
async function generatePutUrl (bucketID: string, path: string) {
const options = {
version: 'v4',
action: 'write',
expires: Date.now() + 60 * 60 * 1000, // 1 hour
} as const

const [url] = await new Storage()
.bucket(bucketID)
.file(path)
.getSignedUrl(options)
}
```

When using the Firestore Emulator we'd like to be able to also write to the emulator bucket. According #3400 this isn't currently supported, however the [comment](https://github.com/firebase/firebase-tools/issues/3400#issuecomment-998369911) at the bottom that suggests using `.publicUrl()` is a workaround for _readable_ URLs.

This issue would be solved if the return value from the `.publicUrl()` accepted a `PUT` by the emulator that uploaded the file. Currently the emulator returns "Not Implemented", but I _suspect_ honouring `PUT` would be fairly straightforward.

To distinguish this from #3400, that issue would be resolved by supporting signed URLs. This issue would be resolved by using `publicUrl` instead of signed URLs (i.e. this issue feels much simpler).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.