Browse Source

Merge pull request #132 from mbrakken/upstream_readme

Upstream readme
main
Jason Gullickson 5 years ago
committed by GitHub
parent
commit
74d20f803b
  1. 11
      README.md
  2. 3
      config.ex
  3. 38
      lib/google-cloud-storage/disk-operations.js

11
README.md

@ -25,6 +25,17 @@ It's important to note that configuring multiple storage devices does not provid
Future versions of JSFS may include an option to use multiple storage locations for the purpose of redundancy.
##REMOTE STORAGE CONFIGURATION
By default, JSFS assumes you are working with a local file system using node's `fs` module. However, JSFS currently supports remote file storage such as blob or object storage services.
To use a remote storage service:
* Copy /lib/fs/disk-operations.js to /lib/your-storage-serice/disk-operations.js
* Update /lib/your-storage-serice/disk-operations.js as necessary (see /lib/google-cloud-storage/disk-operations.js for examples)
* Update `config.CONFIGURED_STORAGE` to `your-storage-service`
* Add any additional configuration as appropriate.
When JSFS boots, it will load `./lib/${config.CONFIGURED_STORAGE || "fs"}/disk-operations.js` for all disk-type operations.
#API
##Keys and Tokens

3
config.ex

@ -6,5 +6,6 @@ module.exports = {
BLOCK_SIZE: 1048576,
LOG_LEVEL: 0,
SERVER_PORT: 7302,
REQUEST_TIMEOUT: 30 // minutes,
REQUEST_TIMEOUT: 30, // minutes
CONFIGURED_STORAGE: "fs"
};

38
lib/google-cloud-storage/disk-operations.js

@ -1,14 +1,40 @@
"use strict";
/* globals require, module */
var config = require("../../config.js");
var gcs = require("@google-cloud/storage")(config.GOOGLE_CLOUD_STORAGE.AUTHENTICATION);
/**
To use google-cloud-storage, you'll need to install it's dependency:
`npm install --save @google-cloud/storage`
and update config.js with additional parameters:
CONFIGURED_STORAGE: "google-cloud-storage",
GOOGLE_CLOUD_STORAGE: {
BUCKET: "your-bucket-name",
AUTHENTICATION: {
projectId: 'your-project-123',
keyFilename: '/path/to/keyfile.json'
}
}
// {
// projectId: 'grape-spaceship-123',
// keyFilename: '/path/to/keyfile.json'
// }
If you are running on a Google Compute Engine VM, you do not need to
include AUTHENTICATION (eg. `config.GOOGLE_CLOUD_STORAGE.AUTHENTICATION`
should return `undefined`).
You will also need to be sure that the authenticated account has "full"
permissions to the Storage API:
https://cloud.google.com/storage/docs/access-control/iam
Further information at
https://github.com/GoogleCloudPlatform/google-cloud-node#google-cloud-storage-beta
JSFS neither endorses nor is endorsed by Google.
**/
var config = require("../../config.js");
var gcs = require("@google-cloud/storage")(config.GOOGLE_CLOUD_STORAGE.AUTHENTICATION);
var bucket = gcs.bucket(config.GOOGLE_CLOUD_STORAGE.BUCKET);
module.exports.read = function(file_path, callback){

Loading…
Cancel
Save