This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Can't connect to Firebase Storage Emulator #875
Copy link
Copy link
Closed
Labels
api: storageIssues related to the googleapis/java-storage API.Issues related to the googleapis/java-storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Environment details
- Specify the API at the beginning of the title. For example, "BigQuery: ...").
General, Core, and Other are also allowed as types - OS type and version: osX 10.15.7
- Java version: 15
- storage version(s):
com.google.cloud:libraries-bom:20.4.0
Steps to reproduce
- Start the firebase emulator suite (including storage) via the npm firebase client.
- Try to create a file using the firetstore emulator
Code example
fun createStorage(): Storage {
val storageHost = System.getenv().getOrDefault(ENV_STORAGE_EMULATOR_HOST, "http://localhost:9199")
println("Using $storageHost for the Storage host")
return StorageOptions
.getDefaultInstance()
.toBuilder()
.setHost(storageHost)
.setCredentials(NoCredentials.getInstance())
.setProjectId("test")
.build()
.service
}suspend fun Storage.upload(from: InputStream, to: BlobId): Unit = withContext(Dispatchers.IO) {
val storage = this@upload
val toInfo = BlobInfo.newBuilder(to).build()
storage
.create(toInfo)
.writer().use { writeChannel ->
val byteBuffer = ByteBuffer.allocate(2048)
from.use { from ->
Channels.newChannel(from).use { fileChannel ->
while (fileChannel.read(byteBuffer) > 0) {
writeChannel.write(byteBuffer)
}
}
}
}
}
Stack trace
Using localhost:8080 for the Firestore host.
It is being configured as an emulator
Using http://localhost:9199 for the Storage host
400 Bad Request
POST http://localhost:9199/upload/storage/v1/b/test/o?projection=full&uploadType=multipart
Bad Request
com.google.cloud.storage.StorageException: 400 Bad Request
POST http://localhost:9199/upload/storage/v1/b/test/o?projection=full&uploadType=multipart
Bad Request
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:233)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:314)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:221)
at com.google.cloud.storage.StorageImpl$3.call(StorageImpl.java:218)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
at com.google.cloud.storage.StorageImpl.internalCreate(StorageImpl.java:217)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:157)
at com.example.test.ProcessController$upload$4.invokeSuspend(ProcessorController.kt:118)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
POST http://localhost:9199/upload/storage/v1/b/test/o?projection=full&uploadType=multipart
Bad Request
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:532)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:455)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.create(HttpStorageRpc.java:311)
... 14 more
It seems like maybe this library doesn't support the local emulator.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/java-storage API.Issues related to the googleapis/java-storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Activity
[-]Can't connect to Storage Emulator[/-][+]Can't connect to Firebase Storage Emulator[/+]JesseLovelace commentedon Jun 17, 2021
The emulator is part of the Firebase SDK right? It looks like you're pointing to it correctly, so it looks to me like it's a bug with the emulator, not the storage client.
danielduhh commentedon Jun 24, 2021
See this thread. The cloud storage for firebase emulator is not compatible with any of the storage clients. It looks like you may have already done this, but please raise this to the firebase tools team as a feature request 🙏🏿 .