storage-abstraction:提供用于与存储进行交互的抽象层; 存储可以是本地存储或在云中

  • n9_569002
  • 202.4KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-05-20 19:06
存储抽象 提供用于与存储进行交互的抽象层; 该存储可以是本地文件系统或云存储。 当前支持本地磁盘存储,Backblaze B2,Google Cloud和Amazon S3以及兼容的云服务。 由于API仅提供基本的存储操作(请参阅),因此该API与云无关。 例如,这意味着您可以使用本地磁盘上的存储来开发应用程序,然后在生产环境中使用Google Cloud或Amazon S3而无需更改任何代码。 目录 createBucket selectBucket clearBucket deleteBucket listBuckets getSelectedBucket addFileFromPath addFileFromBuffer addFileFromReadable getFileAsReadable removeFile sizeOf 文件已存在 listFil
  • storage-abstraction-master
  • spec
  • support
  • jasmine.json
  • publish
  • package.json
  • .npmignore
  • tests
  • data
  • image1.jpg
  • image2.jpg
  • test-config-s3.jasmine.ts
  • keyFile.json
  • util.ts
  • test-config-gcs.jasmine.ts
  • test-config-local.jasmine.ts
  • test.jasmine.ts
  • test.ts
  • test-config-b2.jasmine.ts
  • src
  • template_class.ts
  • AdapterGoogleCloudStorage.ts
  • Storage.ts
  • template_functional.ts
  • AdapterBackblazeB2.ts
  • util.ts
  • AdapterLocal.ts
  • AdapterAmazonS3.ts
  • AdapterBackblazeB2F.ts
  • types.ts
  • AbstractAdapter.ts
  • index.ts
  • tsconfig.json
  • yarn.lock
  • keyFile.json
  • .gitignore
  • package.json
  • package-lock.json
  • .env.default
# <a name='storage-abstraction' rel='nofollow' onclick='return false;'></a>Storage Abstraction Provides an abstraction layer for interacting with a storage; this storage can be a local file system or a cloud storage. Currently local disk storage, Backblaze B2, Google Cloud and Amazon S3 and compliant cloud services are supported. Because the API only provides basic storage operations (see [below](#api-methods)) the API is cloud agnostic. This means for instance that you can develop your application using storage on local disk and then use Google Cloud or Amazon S3 in your production environment without changing any code. ## <a name='table-of-contents' rel='nofollow' onclick='return false;'></a>Table of contents <!-- toc --> - [Instantiate a storage](#instantiate-a-storage) * [Configuration object](#configuration-object) * [Configuration URL](#configuration-url) - [Adapters](#adapters) * [Local storage](#local-storage) * [Google Cloud](#google-cloud) * [Amazon S3](#amazon-s3) * [Backblaze B2](#backblaze-b2) - [API methods](#api-methods) * [init](#init) * [test](#test) * [createBucket](#createbucket) * [selectBucket](#selectbucket) * [clearBucket](#clearbucket) * [deleteBucket](#deletebucket) * [listBuckets](#listbuckets) * [getSelectedBucket](#getselectedbucket) * [addFileFromPath](#addfilefrompath) * [addFileFromBuffer](#addfilefrombuffer) * [addFileFromReadable](#addfilefromreadable) * [getFileAsReadable](#getfileasreadable) * [removeFile](#removefile) * [sizeOf](#sizeof) * [fileExists](#fileexists) * [listFiles](#listfiles) * [getType](#gettype) * [getConfiguration](#getconfiguration) * [switchAdapter](#switchadapter) - [How it works](#how-it-works) - [Adding more adapters](#adding-more-adapters) * [Define your configuration](#define-your-configuration) * [Adapter class](#adapter-class) * [Adapter function](#adapter-function) * [Register your adapter](#register-your-adapter) - [Tests](#tests) - [Example application](#example-application) - [Questions and requests](#questions-and-requests) <!-- tocstop --> ## <a name='instantiate-a-storage' rel='nofollow' onclick='return false;'></a>Instantiate a storage ```javascript const s = new Storage(config); ``` When instantiating a new `Storage` the argument `config` is used to create an adapter that translates the generic API calls to storage specific calls. You can provide the `config` argument in 2 forms: 1. using a configuration object (js: `typeof === "object"` ts: `AdapterConfig`) 2. using a configuration URL (`typeof === "string"`) Internally configuration URL will be converted to a configuration object so any rule that applies to a configuration object also applies to configuration URLs. The configuration must specify a type; the type is used to create the appropriate adapter. The value of the type is one of the enum members of `StorageType`: ```typescript enum StorageType { LOCAL = "local", GCS = "gcs", S3 = "s3", B2 = "b2", } ``` ### <a name='configuration-object' rel='nofollow' onclick='return false;'></a>Configuration object A configuration object extends `IAdapterConfig`: ```typescript interface IAdapterConfig { type: string; slug?: boolean; bucketName?: string; } ``` Besides the mandatory key `type` one or more keys may be mandatory or optional dependent on the type of storage; for instance keys for passing credentials such as `keyFilename` for Google Storage or `accessKeyId` and `secretAccessKey` for Amazon S3, and keys for further configuring the storage service such as `sslEnabled` for Amazon S3. The optional key `slug` determines if bucket names and paths to files in buckets are slugified automatically. Another optional key is `bucketName`; for most cloud storage services it is required to select a bucket after a connection to the service has been made. If you don't want or can't provide a bucket name on initialization you can use `selectBucket` to do so afterwards. ### <a name='configuration-url' rel='nofollow' onclick='return false;'></a>Configuration URL Configuration urls always start with a protocol that defines the type of storage: - `local://` &rarr; local storage - `gcs://` &rarr; Google Cloud - `s3://` &rarr; Amazon S3 - `b2://` &rarr; Backblaze B2 These values match the values in the enum `StorageType` shown above. What follows after the protocol is the part that contains the configuration of the storage. The format of the URL differs per storage type, see the documentation per adapter [below](#adapters) for details. ```typescript // local storage const url = "local://path/to/bucket"; // Amazon S3 const url = "s3://accessKeyId:secretAccessKey@region/bucketName?extraOption1=value1&extraOption2=value2..."; // Google Cloud Storage const url = "gcs://path/to/keyFile.json:projectId@bucketName?extraOption1=value1&extraOption2=value2..."; // Backblaze B2 const url = "b2://applicationKeyId:applicationKey@bucketName?extraOption1=value1&extraOption2=value2..."; ``` ## <a name='adapters' rel='nofollow' onclick='return false;'></a>Adapters The adapters are the key part of this library; where the `Storage` is merely a thin wrapper (see [How it works](#how-it-works)), adapters perform the actual actions on the storage by translating generic API methods calls to storage specific calls. Below follows a description of the available adapters; what the configuration objects and URLs look like and what the default values are. Also per adapter the peer dependencies are listed as a handy copy-pasteble npm command. The peer dependencies are usually wrapper libraries such as aws-sdk but can also be specific modules with a specific functionality such as rimraf for local storage. If you want to use one or more of the adapters in your project make sure you install the required peer dependencies. By installing only the dependencies that you will actually use, your project codebase will stay as slim and maintainable as possible. You can also add more adapters yourself very easily, see [below](#adding-more-adapters) ### <a name='local-storage' rel='nofollow' onclick='return false;'></a>Local storage > peer dependencies: <br/> > `npm i glob rimraf` Configuration object: ```typescript type ConfigLocal = { type: StorageType; directory: string; slug?: boolean; mode?: string | number; }; ``` Configuration url: ```typescript const url = "local://path/to/your/bucket?mode=750"; ``` The key `mode` is used to set the access rights when creating new buckets. The default value is `0o777`. You can pass this value both as a string and as a number. If you use a configuration URL you can only pass values as strings; string values without radix prefix will be interpreted as octal numbers, so "750" is the same as "0o750" and both yield the same numeric value `0o750` or `488` decimal. When using a configuration object you can also pass `mode` as a number, please don't forget the radix prefix if you don't use decimal numbers, e.g. `750` is probably not what you want, pass `0o750` or `488` instead. Best is to use strings to avoid confusion. Example: ```typescript const config = { type: StorageType.LOCAL, directory: "path/to/folder/bucket", mode: "750", }; const s = new Storage(config); // or const url = "local://path/to/folder/bucket?mode=750"; const s = new Storage(url); ``` Files will be stored in `path/to/folder/bucket`, folders will be created if necessary. As you can see the last folder of the directory will be used as bucket; if you call `getSelectedBucket()` the name of this folder will be returned. Note the use of double and triple slashes: ```typescript // example #2 const s = new Storage { type: StorageType.LOCAL, directory: "files", }; const s = new Storage("local://files") // note: 2 slashes s.getConfiguration().directory; // folder where the process runs, process.cwd() s.getConfiguration().bucketName; // 'files' // example #3 const s = new Storage { type: StorageType.LOCAL, directory: "/files", }; const s = new Storage("local:///files") // note: 3 slashes s.getConfiguration().directory; // '/' root folder (may require extra permissions) s.getConfiguration().bucketName; // 'files' ``` ### <a name='google-cloud' rel='nofollow' onclick='return false;'></a>Google Cloud > p
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
    • 卷积神经网络
    • 微电网PSO优化算法
    • SIM800C_MQTT.rar
    • android从bootloader到launcher启动流程整理
      讲述android 开机流程 从boot rom---bootloader---init--zygote---systemserver---ams 并附上自己整理的每个流程的流程图 ,清晰熟悉android 启动流程
    • Aerosim Blockset
      The AeroSim aeronautical simulation blockset provides a complete set of tools for the rapid development of nonlinear 6-degree of freedom aircraft dynamic models. In addition to the basic aircraft dynamics blocks, the library also includes complete aircraft models which can be customized through parameter files.
    • 分数阶混沌系统:分数阶混沌系统的数值解。-matlab开发
      该工具箱包含可用于模拟一些著名的分数阶混沌系统的函数,例如: - 陈的系统, - Arneodo的系统, - Genesio-Tesi 的系统, - 洛伦兹系统, - 牛顿-莱普尼克系统, - 罗斯勒的系统, - Lotka-Volterra系统, - 达芬的系统, - 范德波尔的振荡器, -伏打的系统- 陆氏系统, - 刘的系统, - Chua的系统, - 金融系统, - 3 细胞 CNN。 这些函数以数值方式计算描述混沌系统的分数阶非线性微分方程的解。 每个函数返回总模拟时间的状态轨迹(吸引器)。 更多详情请看书: Ivo Petras,分数阶非线性系统:建模、分析和仿真,Springer,系列:非线性物理科学,2011,ISBN 978-3-642-18100-9。
    • matlabpam代码-dsp-library:用于光通信的MATLABDSP函数库
      matlab pam代码 DSP库 该项目包含几种不同的功能,可将DSP算法应用于光通信。 这些功能适用于相干和非相干(PAM,DMT)光通信。 大多数功能是相互独立的。 因此,该代码中的功能可以轻松使用,并与其他DSP功能结合使用。 用法 功能列表以及简短说明在文件中。 输入和输出参数的描述在每个函数的标题中。 讯号 通常,输入(和输出)信号在第一维度上具有时间(例如,列向量),而第二维度用于一次管理多个信号(例如,不同的极化,不同的参数等)。 之所以选择这种约定,是因为MATLAB通过将列保留在内存的连续部分中来存储矩阵,因此,这种约定比其他方法(行向量)要快。 参数 大多数功能使用参数结构作为输入参数。 函数中使用的参数的描述通常在标头中,而coherent-dsp函数的默认参数在文件中。 参考 执照 此代码在下发布。
    • 有关多目标跟踪的PHD滤波的一些资料
    • stm32-uart-dma:STM32串口DMA模式发送&接收实现,高速串口通信(1.5Mbps)不丢数据
      STM32高速串口通信DMA收发实现 测试平台 平台 晶振 BSP库 串口 STM32F030C8T6 12MHz 标准库 UART1、UART2 STM32F103ZET6 8MHz 标准库 UART1、UART2 ... 实现功能 收/发环形缓冲区 不定长度接收处理 高速(1.5Mbps)通信不丢数据 关键实现 DMA发送模式 线程循环查询发送环形缓冲区数据,然后启动MDA传输 DMA传输完成中断,连续发送 定时器中断周期发送 DMA接收模式 DMA缓存半满中断(如CPU硬件支持,可使用DMA双缓存机制) DMA缓存传输完成中断 串口空闲中断实现 其他 更详细的描述过程参考文章