4front-s3-deployments 中文文档教程
4front-s3-deployments
S3 基于代码部署或 4front 网络平台。 用于存储上传的虚拟应用程序资产,例如 JavaScript、样式表、html 文件、图像等。
虽然可以通过 4front node.js 平台提供静态资产,但直接使用 S3 作为 Web 主机效率更高。 请参阅 AWS 文档,了解如何为静态托管配置存储桶。 作为进一步的优化,您可以在 S3 存储桶 URL 前面配置 CloudFront(或其他 CDN)。 htmlprep 包动态地将您的相对资产路径重写为适当的绝对路径。
对于 4front 平台的本地安装,s3rver 提供了一个利用本地文件系统的 S3 模拟实现。
Installation
npm install 4front-s3-deployments
Usage
var s3Deployments = require('4front-s3-deployments')({
region: 'us-west-2',
bucket: '4front-deployments'
});
您可以传入 AWS.config 对象接受的任何有效选项,包括 region
, accessKeyId
, secretAccessKey
等
API
// Deploy an individual file
s3Deployments.deployFile(appId, versionId, fileInfo, callback);
// Returns a readable stream
s3Deployments.readFileStream(appId, versionId, filePath);
// Delete version
s3Deployments.deleteVersion(appId, versionId, callback);
// Delete all deployed versions for an app
s3Deployments.deleteAllVersions(appId, callback);
// List all the files for a version
s3Deployments.listFiles(appId, versionId, callback);
// Check if file exists
s3Deployments.fileExists(appId, versionId, filePath, callback);
见单元测试 例如调用所有这些函数。
Running Tests
npm test
License
根据 Apache 许可证 2.0 版获得许可。 请参阅顶级文件 LICENSE.txt 和 (http://www.apache.org/licenses/LICENSE-2.0)。
[npm-image]: https://img.shields.io/npm/v/4front-s3-deployments.svg?style=flat [npm-url]:https://npmjs.org/package/4front-s3-deployments [下载图像]:https://img.shields.io/npm/dm/4front-s3-deployments.svg?style=flat [下载网址]:https://npmjs.org/package/4front-s3-deployments
4front-s3-deployments
S3 based code deployments or the 4front web platform. Used to store uploaded virtual app assets such as JavaScripts, stylesheets, html files, images, and more.
Although static assets can be served via the 4front node.js platform, it is more efficient to use S3 as a web host directly. See the AWS docs on how to configure a bucket for static hosting. As a further optimization you can configure CloudFront (or another CDN) in front of the S3 bucket URL. The htmlprep package dynamically rewrites your relative asset paths to the appropriate absolute path.
For a local installation of the 4front platform, the s3rver provides a mock implementation of S3 that utilizes your local filesystem.
Installation
npm install 4front-s3-deployments
Usage
var s3Deployments = require('4front-s3-deployments')({
region: 'us-west-2',
bucket: '4front-deployments'
});
You can pass in any valid option accepted by the AWS.config object including region
, accessKeyId
, secretAccessKey
, etc.
API
// Deploy an individual file
s3Deployments.deployFile(appId, versionId, fileInfo, callback);
// Returns a readable stream
s3Deployments.readFileStream(appId, versionId, filePath);
// Delete version
s3Deployments.deleteVersion(appId, versionId, callback);
// Delete all deployed versions for an app
s3Deployments.deleteAllVersions(appId, callback);
// List all the files for a version
s3Deployments.listFiles(appId, versionId, callback);
// Check if file exists
s3Deployments.fileExists(appId, versionId, filePath, callback);
See the unit tests for example calls of all these functions.
Running Tests
npm test
License
Licensed under the Apache License, Version 2.0. See the top-level file LICENSE.txt and (http://www.apache.org/licenses/LICENSE-2.0).
[npm-image]: https://img.shields.io/npm/v/4front-s3-deployments.svg?style=flat [npm-url]: https://npmjs.org/package/4front-s3-deployments [downloads-image]: https://img.shields.io/npm/dm/4front-s3-deployments.svg?style=flat [downloads-url]: https://npmjs.org/package/4front-s3-deployments