AWS S3 的飞行存储适配器
此软件包包含用于 Google Cloud 存储的 Flystorage 适配器
安装
安装所有需要的软件包
npm install --save @flystorage/file-storage @flystorage/google-cloud-storage @google-cloud/storage
使用量
import {FileStorage} from '@flystorage/file-storage';
import {GoogleCloudStorageStorageAdapter} from '@flystorage/google-cloud-storage';
import {Storage} from '@google-cloud/storage';
const client = new Storage();
const bucket = client.bucket('{bucket-name}}', {
userProject: '{user-project}}',
});
const adapter = new GoogleCloudStorageStorageAdapter(bucket, {
prefix: '{optional-path-prefix}',
});
const storage = new FileStorage(adapter);
QQ 总是使用 FileStorage, 它对于安全和良好的开发者至关重要 经历。 不直接使用适配器.
可见度
建立可检索的能见度对遗留的桶子才有意义。 要使用此功能 将遗留的能见度处理传递给构造者:
import {GoogleCloudStorageStorageAdapter, LegacyVisibilityHandling} from '@flystorage/google-cloud-storage';
const adapter = new GoogleCloudStorageStorageAdapter(bucket, {
prefix: '{optional-path-prefix}',
}, new LegacyVisibilityHandling(
'allUsers', // acl entity, optional
'publicRead', // acl for Visibility.PUBLIC, optional,
'projectPrivate', // acl for Visibility.PRIVATE, optional,
));