Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Cloud Storage with local emulator #18

Closed

Description

@lukesneeringer

From @arbesfeld on October 20, 2016 19:50

There are a few "Mock s3" servers that run in memory/disk. Since the google cloud storage and S3 APIs are the same, I was wondering if there was a way to use one of these servers with the Cloud Storage client? If not, what is the recommended way to use this API for local development?

Copied from original issue: googleapis/google-cloud-node#1731

Activity

  1. lukesneeringer commented on Sep 21, 2017

    @lukesneeringer
    ContributorAuthor

    From @stephenplusplus on October 20, 2016 19:52

    Can you link the mock libraries? I'm not sure they'd be the same, but soon we will support using a custom endpoint which accepts the requests from our API (#1630).

  2. lukesneeringer commented on Sep 21, 2017

    @lukesneeringer
    ContributorAuthor

    From @arbesfeld on October 20, 2016 19:54

    Here are a few :

  3. lukesneeringer commented on Sep 21, 2017

    @lukesneeringer
    ContributorAuthor

    From @nfarina on February 13, 2017 18:40

    I found that it was simple enough to create my own mock classes to emulate Google Cloud Storage just enough for my tests to pass. I posted my code to this gist in case anyone finds it useful as a starting point. Note: written in ES7 with Flow annotations.

  4. stephenplusplus commented on Dec 27, 2017

    @stephenplusplus
    Contributor

    I don't anticipate having an official solution for this. For offline development, you can use any HTTP request interceptor library that may exist. You can see the endpoints we hit in the source code, and if you want to log all of them:

    const Storage = require('@google-cloud/storage')
    const gcs = new Storage()
    
    gcs.interceptors.push({
      request: reqOpts => {
        console.log(reqOpts)
        return reqOpts
      }
    })

    This will log all HTTP requests we make in the format the request module accepts.

    Also, if you pass customEndpoint: true, it will skip the authentication step:

    const Storage = require('@google-cloud/storage')
    const gcs = new Storage({ customEndpoint: true })

    Hopefully this is helpful. Feel free to ask any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: storageIssues related to the googleapis/nodejs-storage API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions