Uploading files to Google Cloud Storage from Localhost or external server

前端 未结 3 1293
无人及你
无人及你 2021-01-22 10:20

I want to upload files to Google Cloud Storage (Bucket) through my PHP or JavaScript application which is hosted in my localhost or external server.

As I tried the Goog

3条回答
  •  执笔经年
    2021-01-22 11:08

    I wrote a package to download / get local file and upload to Google Cloud Storage, maybe it help you: https://github.com/jeansouzak/duf

    use JeanSouzaK\Duf\Duff;
    use JeanSouzaK\Duf\Prepare\WebResource;
    use JeanSouzaK\Duf\Prepare\LocalResource;
    
    $duf = Duff::getInstance(Duff::GOOGLE_CLOUD_STORAGE, [
        'project_id' => 'storage-test-227305',
        'key_path' => '/home/env/storage-test-227305-8472347a39489.json'
    ]);
    
    // - Chaining example -
    $uploadResults = $duf->prepare([
        new LocalResource('imagem', '/home/test/images/test.jpg'),
        new WebResource('teste.png', 'https://dummyimage.com/600x400/000/fff')
    ])->download()->addBucket('your-bucket-name')->upload();
    

提交回复
热议问题