Coder Social home page Coder Social logo

gaefile's Introduction

gaefile

gaefile is an open source golang project that implements simple file uploads and downloads using Google Cloud Storage.

How to use this project?

First, clone it into your $GOPATH.

$ cd $GOPATH/src
$ git clone [email protected]:XiaonuoGantan/gaefile.git

Second, create two files under gaeserver/:

$ cd gaefile
$ touch gaeserver/ServiceAccountAccessID.txt
$ touch gaeserver/ServiceAccountPrivateKey.pem

The content of ServiceAccountAccessID.txt is a one line text which is your Google Service Account's email address that looks like [email protected].

The content of ServiceAccountPrivateKey.pem is the Google service account private key. It is obtainable from the Google Developer Console. Details about how to obtain it is available at https://godoc.org/google.golang.org/cloud/storage#SignedURLOptions.

Third, change the option GOOGLE_CLOUD_STAORAGE_BUCKET in gaeserver/app.yaml to your own cloud storage bucket.

Fourth, run the server $ goapp serve -port 8090 -host 0.0.0.0 gaeserver.

How to upload and download files?

Upload files:

$ cd gaeserver/sample_images
$ curl -X PUT -H 'X-Gaefile-Filename: image.jpeg' -H 'Content-Type: image/jpeg' --data-binary "@sample_image_1.jpg"  http://localhost:8090
{"key":"zHcmkYxgCZVw7A==_image.jpeg"}

Download files:

$ cd gaeserver/sample_images
$ curl -X GET -L http://localhost:8090/zHcmkYxgCZVw7A==_image.jpeg > downloaded.jpg
$ diff sample_image_1.jpg downloaded.jpg

If everything works, then the diff command above should output nothing since the downloaded image and the sample image are identical.

gaefile's People

Contributors

xiaonuogantan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.