Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

FIREBASE_STORAGE_EMULATOR_HOST Environment Variable does not work with Admin SDK

Đang mở
#874 5 bình luận 8 reaction 1 người được giao Xem trên GitHub

@jonathanedey đang làm issue này rồi.

Từ ngày 14/2/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

api: storage
My environment:
  • Operating System version: Mac OS Sonoma 14.0 (23A344)
  • Firebase Admin SDK version: 9.2.0
  • Firebase Product: Storage Emulator
The problem:

When setting the environment variable "FIREBASE_STORAGE_EMULATOR_HOST" to 127.0.0.1:9199 (the default Storage Emulator Port and IP) to use the Firebase Storage Emulator the Admin SDK does not detect this environment variable.

Other Environment variables such as "FIREBASE_DATABASE_EMULATOR_HOST" and "FIRESTORE_EMULATOR_HOST" do work perfectly fine and as expected. They make a connection to emulators on the device.

I have gone as far to test and see if this issue is persistent on other Admin SDK's such as the Node.Js SDK. It is NOT an issue that persists on the SDK for Node.js.

As see here, this was previously an issue filed for the Firebase Admin SDKin the GO Repository for the Admin SDK (see here) and was fixed here (see here) and has been since claimed to be fixed and the logic used in the Node Admin SDK project will be implemented.

The same issue previously on the Go Repo, appears to be present on the Admin Java SDK. Even using the "STORAGE_EMULATOR_HOST" environment variable as it was changed to in the GO repo, does not work.

Documentation on the Firebase Admin SDK docs is also incorrect if this is the case.

Screenshot 2023-11-03 at 5 32 06 PM
Steps to reproduce:

Set either environment variable "STORAGE_EMULATOR_HOST" or "FIREBASE_STORAGE_EMULATOR_HOST" to your Emulator host address and port (the default is 127.0.0.1:9199)

Use the Java Admin SDK to try and make a call like normal.

See it fail and use the production Cloud Storage instance.

Relevant Code:

Environment Variable Set via Intellij Run Configuration

Screenshot 2023-11-03 at 5 30 56 PM
    InputStream input = this.getClass().getResourceAsStream("/service-account.json");
    assert input != null;
    GoogleCredentials googleCredentials = GoogleCredentials.fromStream(input);


    FirebaseOptions options = FirebaseOptions.builder()
            .setCredentials(googleCredentials)
            .setProjectId("project-id")
            .setDatabaseUrl("https://project-id-default-rtdb.firebaseio.com")
            .setStorageBucket("project-id.appspot.com")
            .build();


    FirebaseApp.initializeApp(options);

    InputStream fileInput = this.getClass().getResourceAsStream("/someFile.anyExtension");
    Bucket bucket = StorageClient.getInstance().bucket();
    bucket.create("someFile.anyExtension", fileInput, "application/anyExtension");
Ngôn ngữ chính
Java
Star
620
Fork
305
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
4

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-java

Tất cả issue của firebase/firebase-admin-java

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.