donglu2523 2016-07-04 11:38 采纳率: 100%
浏览 31

firebase存储并从php上传

I have a php application and from this i need upload images to google firebase storage. I had seen snippets that write to and read from realtime database but couldnt find any code that upload from php to firebase storage.

Any help will be much appreciated.

Tismon Varghese

  • 写回答

1条回答 默认 最新

  • douyu9159 2016-07-04 17:10
    关注

    We recommend using the Google API Client PHP library for this, as Firebase Storage is backed by Google Cloud Storage. Firebase Storage doesn't provide a PHP client for front end code though.

    From the GCS PHP example code:

    // composer autoloading
    require_once __DIR__ . '/vendor/autoload.php';
    
    // grab the first argument
    if (empty($argv[1])) {
        die("usage: php listBuckets [project_id]
    ");
    }
    
    $projectId = $argv[1];
    
    // Authenticate your API Client
    $client = new Google_Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope(Google_Service_Storage::DEVSTORAGE_FULL_CONTROL);
    
    $storage = new Google_Service_Storage($client);
    
    /**
     * Google Cloud Storage API request to retrieve the list of buckets in your project.
     */
    $buckets = $storage->buckets->listBuckets($projectId);
    
    foreach ($buckets['items'] as $bucket) {
        printf("%s
    ", $bucket->getName());
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)