Coder Social home page Coder Social logo

cdn-uploader's Introduction

cdn-uploader

Small tool uploading assets to CDN backend (Google Cloud Storage)

Build Status Greenkeeper badge

Requirements

You must either specify key-filename or specify credentials which is a base64 encoded JSON.stringify version of the JSON based keyfile containing credentials used when talking to Google Cloud Storage (GCS).

//base 64 encoded keyfile
const credentials = require('keyfile.json');
const credentialString = JSON.stringify(credentials);
return new Buffer(credentialString).toString('base64');

Usage

Install:

$ npm install @finn-no/cdn-uploader -g

Actual usage:

$ cdn-uploader /tmp/cdn-assets -a test-app
-- Uploaded assets --
test-app/example.jpg
test-app/css/SDFSDF.finn.css
test-app/js/SDFSDF.finn.js

Get help:

$ cdn-uploader -h
cdn-uploader [options] <assetsFolder>

Options:
  --app-prefix, -a    Application prefix used in the CDN url [string] [required]
  --key-filename, -k  JSON key file used to authenticate with Google Cloud
                      Platform.
                      If not set, the credentials option is used.       [string]
  --credentials, -c   Stringified and base64 encoded version of the JSON key
                      file used to authenticate with Google Cloud Platform.
                      Can also be set as CDN_UPLOADER_CREDENTIALS environment
                      variable                                          [string]
  --bucket-name, -b   Google Cloud Storage bucket to use.
                                              [string] [default: "fiaas-assets"]
  --project-id, -p    Google Cloud Storage projectId.
                                                 [string] [default: "fiaas-gke"]
  --cache-control     Override the cache-control header for the assets
                                   [string] [default: "public, max-age=2592000"]
  --flatten, -f       Flatten filestructure           [boolean] [default: false]
  --dry-run, -n       Print a list of which files would be uploaded    [boolean]
  --resumable, -r     Resumable upload                 [boolean] [default: true]
  --validation, -V    Validation for upload            [boolean] [default: true]
  --help, -h, -?      Show help                                        [boolean]
  --version, -v       Show version number                              [boolean]

All options can also be set as environment variables, using the CDN_UPLOADER_ prefix. E.g.: CDN_UPLOADER_APP_PREFIX, CDN_UPLOADER_CREDENTIALS, etc.

Excluded files

All files or folder beginning with a "." is automatically excluded (e.g. .gitignore) and will not be uploaded.

Advanced

You may also override other options if you like (handy for testing)

  • --key-filename - JSON key file used to authenticate with GCP. If not set CDN_UPLOADER_CREDENTIALS environment variable is used.
  • --bucket-name - GCS bucket to use.
  • --project-id - GCS projectId.

You can also use environment variables for these options, just use the prefix CDN_UPLOADER_.

Where does my files end up?

The files uploaded to GCS is made available on the public GCS hosting at:

https://storage.googleapis.com/<bucket-name>/<app-prefix>/<assetName>

This is again exposed by our CDN at:

https://static.finncdn.no/_c/<app-prefix>/<assetName>

Cache time?

All files uploaded to CDN is configured with Cache-Control: public, max-age=2592000, meaning that clients may cache the assets for up to 30 days.

cdn-uploader's People

Contributors

greenkeeper[bot] avatar greenkeeperio-bot avatar henrik242 avatar ivarconr avatar runeh avatar simenb avatar stigkj avatar sveisvei avatar trygve-lie avatar

Stargazers

 avatar

Watchers

 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.