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());
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法