0.0.5 • Published 10 months ago
@snewbie/capacitor-s3 v0.0.5
@snewbie/capacitor-s3
S3 Capacitor Plugin
Install
npm install @snewbie/capacitor-s3
npx cap sync
Usage
import { S3 } from '@snewbie/capacitor-s3';
const s3Instance = await S3.create({
credentials: {
accessKey: 'my-key',
secretKey: 'my-secret',
},
endpoint: 'https://s3.example.com',
bucketName: 'my-bucket',
});
API
create(...)
create(args: { credentials: BasicAWSCredentials; endpoint: string; bucketName: string; }) => Promise<S3>
创建 S3 实例。
Param | Type |
---|---|
args | { credentials: BasicAWSCredentials; endpoint: string; bucketName: string; } |
Returns: Promise<S3>
Since: 0.0.1
putString(...)
putString(args: { key: string; value: string; }) => Promise<PutStringResult>
将字符串上传到 S3。
Param | Type |
---|---|
args | { key: string; value: string; } |
Returns: Promise<PutStringResult>
Since: 0.0.1
getString(...)
getString(args: { key: string; }) => Promise<string>
从 S3 获取字符串。
Param | Type |
---|---|
args | { key: string; } |
Returns: Promise<string>
Since: 0.0.1
doesObjectExist(...)
doesObjectExist(args: { key: string; }) => Promise<boolean>
检查对象是否存在。
Param | Type |
---|---|
args | { key: string; } |
Returns: Promise<boolean>
Since: 0.0.1
deleteObject(...)
deleteObject(args: { key: string; }) => Promise<void>
删除对象。
Param | Type |
---|---|
args | { key: string; } |
Since: 0.0.1
Interfaces
BasicAWSCredentials
Prop | Type | Since |
---|---|---|
accessKey | string | 0.0.1 |
secretKey | string | 0.0.1 |
PutStringResult
Prop | Type | Description |
---|---|---|
versionId | string | 新上传对象的可选版本 ID。仅当为对象上传到的存储桶启用了对象版本控制时,才会设置此字段。 |
etag | string | 新创建的对象的 ETag 值。 |
contentMd5 | string | 返回在客户端计算的对象内容的 Base64 编码 MD5 哈希。如果禁用了 MD5 验证,并且调用方在发送 PutObjectRequest 时未在 ObjectMetadata 中提供 MD5 哈希,则此方法返回 null。 |