Skip to main content

Overview

Pub Version

CloudBase Flutter SDK enables you to use CloudBase capabilities in Flutter applications, including authentication, data models, MySQL database, cloud functions, cloud hosting, APIs, and more. For usage, please refer to CloudBase Flutter SDK, or check the sample code.

Note

CloudBase Flutter SDK is fully aligned with HTTP API

SDK is categorized by functionality:


Basic Usage Example

accessKey can be generated in CloudBase Platform/API Key Configuration

import 'package:cloudbase_flutter/cloudbase_flutter.dart';

// Initialize (async)
final app = await CloudBase.init(
env: 'your-env-id', // Replace with your environment ID
region: 'ap-shanghai', // Region, default is Shanghai
accessKey: 'your-key', // Fill in the generated Publishable Key
authConfig: AuthConfig(
detectSessionInUrl: true, // Optional: automatically detect OAuth parameters in URL
),
);

final auth = app.auth;

Authentication

signUp

Future<SignUpRes> auth.signUp(SignUpReq params)

Register a new user account using smart registration and login flow.

  • Creates a new user account
  • Uses smart registration and login flow: send verification code → wait for user input → smart judgment of user existence → auto login or register and login
  • If user already exists, directly login; if user does not exist, register new user and auto login

参数

params
SignUpReq

返回

Future
SignUpRes

示例


signInAnonymously

Future<SignInRes> auth.signInAnonymously({String? providerToken})

Anonymous login, creates a temporary anonymous user account.

  • Creates a temporary anonymous user account
  • No identity verification info needed
  • Suitable for scenarios requiring temporary access

参数

providerToken
String?

Third-party platform token, used to associate third-party platform identity

返回

Future
SignInRes

示例


signInWithPassword

Future<SignInRes> auth.signInWithPassword(SignInWithPasswordReq params)

Login with password. Supports login via username, email, or phone number.

参数

params
SignInWithPasswordReq

返回

Future
SignInRes

示例


signInWithOtp

Future<SignInWithOtpRes> auth.signInWithOtp(SignInWithOtpReq params)

Login with OTP (one-time verification code). After calling, a verification code will be sent. You need to complete verification through the returned verifyOtp callback.

  • If the user does not exist, a user will be created by default. You can control whether to automatically create a user with the shouldCreateUser parameter (default is true)

参数

params
SignInWithOtpReq

返回

Future
SignInWithOtpRes

示例


signInWithOAuth

Future<SignInOAuthRes> auth.signInWithOAuth(SignInWithOAuthReq params)

Login with OAuth third-party platform. Returns authorization URL, you need to guide the user to redirect to this URL to complete authorization.

参数

params
SignInWithOAuthReq

返回

Future
SignInOAuthRes

示例


signInWithIdToken

Future<SignInRes> auth.signInWithIdToken(SignInWithIdTokenReq params)

Login with IdToken. Suitable for scenarios where third-party platform tokens have been obtained.

参数

params
SignInWithIdTokenReq

返回

Future
SignInRes

示例


signInWithCustomTicket

Future<SignInRes> auth.signInWithCustomTicket(Future<String> Function() getTicketFn)

Login with custom ticket. By passing an async function to get the ticket, the server generates the ticket and completes the login.

参数

getTicketFn
Future<String> Function()

Async function to get custom login ticket

返回

Future
SignInRes

示例


Session Management

getSession

Future<SignInRes> auth.getSession();

Get current session. If token has expired, it will be automatically refreshed.

参数

无参数

返回

Future
SignInRes

示例


refreshSession

Future<SignInRes> auth.refreshSession([String? refreshToken])

Refresh session. Use Refresh Token to get a new Access Token.

参数

refreshToken
String?

Refresh token (optional, defaults to current session's refreshToken)

返回

Future
SignInRes

示例


setSession

Future<SignInRes> auth.setSession(SetSessionReq params)

Set session. Restore session state with Refresh Token.

参数

params
SetSessionReq

返回

Future
SignInRes

示例


signOut

Future<SignOutRes> auth.signOut([SignOutReq? params])

Logout. Clear local session and notify server to revoke token.

参数

params
SignOutReq?

Logout configuration options (optional)

返回

Future
SignOutRes

示例


onAuthStateChange

OnAuthStateChangeResult auth.onAuthStateChange(OnAuthStateChangeCallback callback)

Listen for authentication state changes. Supports listening for login, logout, token refresh, and user update events.

参数

callback
void Function(AuthStateChangeEvent, Session?, AuthStateChangeInfo?)

State change callback function

返回

OnAuthStateChangeResult
OnAuthStateChangeResult

示例


getClaims

Future<GetClaimsRes> auth.getClaims();

Get JWT Claims of current Access Token (token claims).

参数

无参数

返回

Future
GetClaimsRes

示例


User Management

getUser

Future<GetUserRes> auth.getUser();

Get current logged-in user info.

参数

无参数

返回

Future
GetUserRes

示例


refreshUser

Future<SignInRes> auth.refreshUser();

Refresh user info. Re-fetch the latest user data from server and update local session.

参数

无参数

返回

Future
SignInRes

示例


updateUser

Future<UpdateUserRes> auth.updateUser(UpdateUserReq params)

Update user info. If updating email or phone number, verification code verification is required.

参数

params
UpdateUserReq

返回

Future
UpdateUserRes

示例


deleteUser

Future<CloudBaseResponse<void>> auth.deleteUser(DeleteUserReq params)

Delete current user. Password is required for security verification.

参数

params
DeleteUserReq

返回

Future
CloudBaseResponse<void>

示例


Identity Source Management

getUserIdentities

Future<GetUserIdentitiesRes> auth.getUserIdentities();

Get the list of identity sources bound to the current user.

参数

无参数

返回

Future
GetUserIdentitiesRes

示例


linkIdentity

Future<LinkIdentityRes> auth.linkIdentity(LinkIdentityReq params)

Bind third-party identity source. Will redirect to third-party authorization page to complete binding.

参数

params
LinkIdentityReq

返回

Future
LinkIdentityRes

示例


unlinkIdentity

Future<CloudBaseResponse<void>> auth.unlinkIdentity(UnlinkIdentityReq params)

Unbind third-party identity source.

参数

params
UnlinkIdentityReq

返回

Future
CloudBaseResponse<void>

示例


Password Management

resetPasswordForEmail

Future<ResetPasswordForEmailRes> auth.resetPasswordForEmail(String emailOrPhone, {String? redirectTo})

Reset password via email or phone number. After calling, a verification code will be sent. You need to complete password reset through the returned updateUser callback.

参数

emailOrPhone
String

Email or phone number

redirectTo
String?

Redirect URL

返回

Future
ResetPasswordForEmailRes

示例


resetPasswordForOld

Future<SignInRes> auth.resetPasswordForOld(ResetPasswordForOldReq params)

Reset password with old password.

参数

params
ResetPasswordForOldReq

返回

Future
SignInRes

示例


reauthenticate

Future<ReauthenticateRes> auth.reauthenticate();

Re-authenticate. Send verification code to user's email or phone number. After verification, sensitive operations can be performed (such as setting a new password).

参数

无参数

返回

Future
ReauthenticateRes

示例


Verification Management

getVerification

Future<GetVerificationRes> auth.getVerification(GetVerificationReq params)

Send verification code. Supports sending to email or phone number.

参数

params
GetVerificationReq

返回

Future
GetVerificationRes

示例


verify

Future<VerifyRes> auth.verify(VerifyReq params)

Verify verification code (for email/phone verification).

参数

params
VerifyReq

返回

Future
VerifyRes

示例


verifyOAuth

Future<SignInRes> auth.verifyOAuth(VerifyOAuthReq params)

Verify OAuth callback. Handle the callback after user authorization on third-party platform.

参数

params
VerifyOAuthReq

返回

Future
SignInRes

示例


verifyOtp

Future<SignInRes> auth.verifyOtp(VerifyOtpParams params)

Verify OTP (one-time password). Used to verify the verification code sent by signInWithOtp or signUp.

参数

params
VerifyOtpParams

返回

Future
SignInRes

示例


resend

Future<ResendRes> auth.resend(ResendReq params)

Resend verification code.

参数

params
ResendReq

返回

Future
ResendRes

示例


getCaptchaToken

Future<GetCaptchaTokenRes> auth.getCaptchaToken()

Get CAPTCHA token. Used to get CAPTCHA verification token before sending verification code.

参数

无参数

返回

Future
GetCaptchaTokenRes

示例


createCaptchaData

Future<CreateCaptchaDataRes> auth.createCaptchaData(CreateCaptchaDataReq params)

Create CAPTCHA verification data. Used to initialize CAPTCHA challenge.

参数

params
CreateCaptchaDataReq

返回

Future
CreateCaptchaDataRes

示例


verifyCaptchaData

Future<VerifyCaptchaDataRes> auth.verifyCaptchaData(VerifyCaptchaDataReq params)

Verify CAPTCHA. Validate user's CAPTCHA response.

参数

params
VerifyCaptchaDataReq

返回

Future
VerifyCaptchaDataRes

示例


clearCaptchaToken

Future<ClearCaptchaTokenRes> auth.clearCaptchaToken()

Clear CAPTCHA token. Clean up CAPTCHA state after verification.

参数

无参数

返回

Future
ClearCaptchaTokenRes

示例


Data Model

getById

Future<GetByIdRes> app.data.model(collectionName).getById(String id)

Get a single record by ID.

参数

id
String

Record ID

返回

Future
GetByIdRes

示例


get

Future<GetRes> app.data.model(collectionName).get([GetReq? params])

Query records with filters. Supports WHERE conditions, sorting, pagination, etc.

参数

params
GetReq?

Query parameters (optional)

返回

Future
GetRes

示例


list

Future<ModelFindManyResponse> app.models.list({
required String modelName,
Map<String, dynamic>? filter,
Map<String, dynamic>? select,
int? pageSize,
int? pageNumber,
bool? getCount,
List<Map<String, String>>? orderBy,
})

Query multiple records. Supports filter conditions, field selection, pagination, and sorting.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>?

Filter condition, format: {'where': {'field': {'\$eq': 'value'}}}

select
Map<String, dynamic>?

Field selection, format: {'\$master': true} or {'field': true}

pageSize
int?

Page size, default 10

pageNumber
int?

Page number, default 1

getCount
bool?

Whether to return total count

orderBy
List<Map<String, String>>?

Sorting, up to 3 fields, format: [{'field': 'desc'}]

返回

Future
ModelFindManyResponse

示例


listSimple

Future<ModelFindManyResponse> app.models.listSimple({required String modelName, int? pageSize, int? pageNumber, bool? getCount})

Simple query for multiple records (GET request, only supports pagination parameters).

参数

modelName
String

Data model identifier

pageSize
int?

Page size

pageNumber
int?

Page number, default 1

getCount
bool?

Whether to return total count, default false

返回

Future
ModelFindManyResponse

示例


create

Future<ModelCreateResponse> app.models.create({required String modelName, required Map<String, dynamic> data})

Create a single record.

参数

modelName
String

Data model identifier

data
Map<String, dynamic>

Record data

返回

Future
ModelCreateResponse

示例


createMany

Future<ModelCreateManyResponse> app.models.createMany({required String modelName, required List<Map<String, dynamic>> data})

Batch create records.

参数

modelName
String

Data model identifier

data
List<Map<String, dynamic>>

List of records to create

返回

Future
ModelCreateManyResponse

示例


update

Future<ModelUpdateDeleteResponse> app.models.update({required String modelName, required Map<String, dynamic> filter, required Map<String, dynamic> data})

Update a single record.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>

Filter condition

data
Map<String, dynamic>

Data to update

返回

Future
ModelUpdateDeleteResponse

示例


updateMany

Future<ModelUpdateDeleteManyResponse> app.models.updateMany({required String modelName, required Map<String, dynamic> filter, required Map<String, dynamic> data})

Batch update records.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>

Filter condition

data
Map<String, dynamic>

Data to update

返回

Future
ModelUpdateDeleteManyResponse

示例


upsert

Future<ModelUpsertResponse> app.models.upsert({required String modelName, required Map<String, dynamic> filter, Map<String, dynamic>? create, Map<String, dynamic>? update})

Create or update a single record (Upsert). If a matching record is found, it will be updated; otherwise, a new record will be created.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>

Filter condition

create
Map<String, dynamic>?

Data to create when record does not exist

update
Map<String, dynamic>?

Data to update when record already exists

返回

Future
ModelUpsertResponse

示例


deleteById

Future<ModelUpdateDeleteResponse> app.models.deleteById({required String modelName, required String recordId})

Delete a single record by ID.

参数

modelName
String

Data model identifier

recordId
String

Record ID

返回

Future
ModelUpdateDeleteResponse

示例


deleteRecord

Future<ModelUpdateDeleteResponse> app.models.deleteRecord({required String modelName, required Map<String, dynamic> filter})

Delete a single record by condition.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>

Filter condition

返回

Future
ModelUpdateDeleteResponse

示例


deleteMany

Future<ModelUpdateDeleteManyResponse> app.models.deleteMany({required String modelName, required Map<String, dynamic> filter})

Batch delete records.

参数

modelName
String

Data model identifier

filter
Map<String, dynamic>

Filter condition

返回

Future
ModelUpdateDeleteManyResponse

示例


mysqlCommand

Future<ModelMysqlCommandResponse> app.models.mysqlCommand({required String sqlTemplate, List<ModelMysqlParameter>? parameter, ModelMysqlConfig? config})

Execute MySQL commands. Supports parameterized queries.

参数

sqlTemplate
String

SQL statement, supports parameter placeholders {{ var }}

parameter
List<ModelMysqlParameter>?

SQL parameter list

config
ModelMysqlConfig?

Execution config (timeout, preparedStatements, dbLinkName)

返回

Future
ModelMysqlCommandResponse

示例


Data Source Queries

getAggregateDataSourceList

Future<AggregateDataSourceListResponse> app.models.getAggregateDataSourceList({
List<String>? idList,
List<String>? nameList,
int? pageSize,
int? pageNumber,
bool? getCount,
List<Map<String, String>>? orderBy,
})

Query aggregate data source list (GET request, supports pagination and sorting).

参数

idList
List<String>?

Data source ID list

nameList
List<String>?

Data source name list

pageSize
int?

Page size, default 10

pageNumber
int?

Page number, default 1

getCount
bool?

Whether to return total count

orderBy
List<Map<String, String>>?

Sorting, format: [{'field': 'desc'}]

返回

Future
AggregateDataSourceListResponse

示例


getDataSourceAggregateDetail

Future<DataSourceAggregateDetailResponse> app.models.getDataSourceAggregateDetail({
String? datasourceId,
String? dataSourceName,
String? viewId,
int? queryPublish,
bool? queryModelRelation,
String? dbInstanceType,
String? databaseTableName,
})

Query aggregate data source detail by conditions. datasourceId and dataSourceName cannot both be empty.

参数

datasourceId
String?

Data source ID (cannot both be empty with dataSourceName)

dataSourceName
String?

Data source name (cannot both be empty with datasourceId)

viewId
String?

View ID

queryPublish
int?

Query published data source (0: preview, 1: published)

queryModelRelation
bool?

Whether to query relation

dbInstanceType
String?

DB instance type

databaseTableName
String?

Database table name

返回

Future
DataSourceAggregateDetailResponse

示例


getDataSourceByTableName

Future<DataSourceByTableNameResponse> app.models.getDataSourceByTableName({required List<String> tableNames})

Query data source schema definition by database table name.

参数

tableNames
List<String>

Database table name list

返回

Future
DataSourceByTableNameResponse

示例


getBasicDataSourceList

Future<BasicDataSourceListResponse> app.models.getBasicDataSourceList({
List<String>? idList,
List<String>? nameList,
int? pageNum,
int? pageSize,
bool? queryAll,
List<DataSourceQueryFilter>? queryFilterList,
bool? onlyFlexDb,
})

Query basic data source list by conditions (POST request, supports filter conditions).

参数

idList
List<String>?

Data source ID list

nameList
List<String>?

Data source name list

pageNum
int?

Page number, default 1

pageSize
int?

Page size, default 10

queryAll
bool?

Whether to query all

queryFilterList
List<DataSourceQueryFilter>?

Query filter list

onlyFlexDb
bool?

Whether to query only flexdb type

返回

Future
BasicDataSourceListResponse

示例


getBasicDataSource

Future<BasicDataSourceResponse> app.models.getBasicDataSource({
String? datasourceId,
String? dataSourceName,
String? viewId,
int? queryPublish,
bool? queryModelRelation,
String? dbInstanceType,
String? databaseTableName,
})

Query basic data source info by conditions. datasourceId and dataSourceName cannot both be empty.

参数

datasourceId
String?

Data source ID (cannot both be empty with dataSourceName)

dataSourceName
String?

Data source name (cannot both be empty with datasourceId)

viewId
String?

View ID

queryPublish
int?

Query published data source (0: preview, 1: published)

queryModelRelation
bool?

Whether to query relation

dbInstanceType
String?

DB instance type

databaseTableName
String?

Database table name

返回

Future
BasicDataSourceResponse

示例


getSchemaList

Future<DataSourceSchemaListResponse> app.models.getSchemaList({List<String>? dataSourceNameList})

Query all data source schemas in the environment. If no parameters are provided, all schemas are returned.

参数

dataSourceNameList
List<String>?

Data source name list (optional, query all if not provided)

返回

Future
DataSourceSchemaListResponse

示例


getTableName

Future<DataSourceTableNameResponse> app.models.getTableName({String? dataSourceName})

Query the corresponding database table name by data source name.

参数

dataSourceName
String?

Data source name

返回

Future
DataSourceTableNameResponse

示例


MySQL Database

query

Future<MySqlResponse> app.mysql.query({required String table, String? schema, String? instance, MySqlQueryOptions? options})

Query MySQL data. Supports field selection, pagination, sorting, and filter conditions.

Supported filter operators: eq (equal), neq (not equal), gt (greater than), gte (greater than or equal), lt (less than), lte (less than or equal), like (fuzzy match), in (in list), is (null check)

参数

table
String

Table name

schema
String?

Database name

instance
String?

Database instance identifier (requires schema)

options
MySqlQueryOptions?

Query options

返回

Future
MySqlResponse

示例


insert

Future<MySqlWriteResponse> app.mysql.insert({required String table, required dynamic data, String? schema, String? instance, bool? upsert, String? onConflict})

Insert data. Supports single and batch insert, as well as Upsert mode.

参数

table
String

Table name

data
dynamic

Insert data, single Map or batch List<Map>

schema
String?

Database name

instance
String?

Database instance identifier

upsert
bool?

Whether to enable Upsert mode (default false)

onConflict
String?

Upsert conflict field

返回

Future
MySqlWriteResponse

示例


update (MySQL)

Future<MySqlWriteResponse> app.mysql.update({required String table, required Map<String, dynamic> data, required Map<String, String> filters, String? schema, String? instance})

Update MySQL data. WHERE condition is required.

参数

table
String

Table name

data
Map<String, dynamic>

Data to update

filters
Map<String, String>

WHERE condition (cannot be empty)

schema
String?

Database name

instance
String?

Database instance identifier

返回

Future
MySqlWriteResponse

示例


delete (MySQL)

Future<MySqlWriteResponse> app.mysql.delete({required String table, required Map<String, String> filters, String? schema, String? instance})

Delete MySQL data. WHERE condition is required.

参数

table
String

Table name

filters
Map<String, String>

WHERE condition (cannot be empty)

schema
String?

Database name

instance
String?

Database instance identifier

返回

Future
MySqlWriteResponse

示例


count

Future<MySqlCountResponse> app.mysql.count({required String table, Map<String, String>? filters, String? schema, String? instance})

Count MySQL data records.

参数

table
String

Table name

filters
Map<String, String>?

Filter conditions

schema
String?

Database name

instance
String?

Database instance identifier

返回

Future
MySqlCountResponse

示例


Cloud Functions

callFunction

Future<FunctionResponse> app.callFunction({
required String name,
FunctionType? type,
Map<String, dynamic>? data,
HttpMethod? method,
String? path,
Map<String, String>? header,
bool? parse,
})

Call cloud function. Supports both basic cloud functions and function-type cloud run.

参数

name
String

Function/service name

type
FunctionType?

Call type: FunctionType.function (default) / FunctionType.cloudrun

data
Map<String, dynamic>?

Request data

method
HttpMethod?

HTTP method (only valid for cloudrun type, default POST)

path
String?

HTTP path (only valid for cloudrun type, default /)

header
Map<String, String>?

HTTP headers (only valid for cloudrun type)

parse
bool?

Whether to parse return object (only valid for function type, default true)

返回

Future
FunctionResponse

示例


Cloud Run

callContainer

Future<CloudRunResponse> app.callContainer({
required String name,
HttpMethod? method,
String? path,
Map<String, String>? header,
Map<String, dynamic>? data,
})

Call cloud run container service. Supports custom HTTP method, path, and headers.

参数

name
String

Cloud run service name

method
HttpMethod?

HTTP request method (default GET)

path
String?

HTTP request path (default /)

header
Map<String, String>?

HTTP request headers

data
Map<String, dynamic>?

HTTP request body

返回

Future
CloudRunResponse

示例


APIs

apis[name]

ApiMethodProxy app.apis[String apiName]

Call API gateway interface. Supports accessing API proxy objects via subscript operator for chained calls. Supports GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH methods.

参数

apiName
String

API name

返回

ApiMethodProxy
ApiMethodProxy

API method proxy object, supports chained calls

ApiResponse
ApiResponse

API response

示例


Cloud Storage

Cloud Storage module provides file upload, download, delete, copy, move and other operations.

Initialization

final app = await CloudBase.init(
env: 'your-env-id',
accessKey: 'your-access-key',
);

final storage = app.storage.from();

upload

Future<StorageResponse<StorageUploadResult>> storage.upload(
String path,
List<int> fileData, {
StorageUploadOptions? options,
})

Upload file to cloud storage. This method will first get upload info, then upload file to COS, and finally return fileID.

参数

path
String

Cloud storage relative path, e.g. `images/photo.jpg`.

fileData
List<int>

File byte data.

options
StorageUploadOptions

Upload options.

返回

data.id
String?

CloudBase fileID.

data.path
String?

Upload path.

data.fullPath
String?

File full path.

error
StorageError?

Error message.

示例


getUploadInfo

Future<StorageResponse<List<StorageUploadInfo>>> storage.getUploadInfo(
List<String> paths,
)

Get file upload info. Returns upload URL and other info for client to directly upload files to COS.

参数

paths
List<String>

File path list (cloud storage relative path).

返回

data
List<StorageUploadInfo>?

Upload info list.

error
StorageError?

Error message.

示例


getDownloadUrls

Future<StorageResponse<List<StorageDownloadInfo>>> storage.getDownloadUrls(
List<String> fileIds, {
int? expiresIn,
})

Get file download URLs.

参数

fileIds
List<String>

File ID list (full cloudObjectId, e.g. `cloud://envId.xxx/path/file.jpg`).

expiresIn
int?

Reserved parameter, current API does not support custom expiration time.

返回

data
List<StorageDownloadInfo>?

Download info list.

error
StorageError?

Error message.

示例


createSignedUrl

Future<StorageResponse<String>> storage.createSignedUrl(
String fileId,
int expiresIn,
)

Create signed URL (temporary access link).

参数

fileId
String

Full fileID.

expiresIn
int

Expiration time (seconds).

返回

data
String?

Signed URL.

error
StorageError?

Error message.

示例


createSignedUrls

Future<StorageResponse<List<StorageDownloadInfo>>> storage.createSignedUrls(
List<String> fileIds,
int expiresIn,
)

Batch create signed URLs.

参数

fileIds
List<String>

Full fileID list.

expiresIn
int

Expiration time (seconds).

返回

data
List<StorageDownloadInfo>?

Download info list.

error
StorageError?

Error message.

示例


remove

Future<StorageResponse<List<StorageDeleteResult>>> storage.remove(
List<String> fileIds,
)

Delete files.

参数

fileIds
List<String>

File ID list to delete (full fileID).

返回

data
List<StorageDeleteResult>?

Delete result list.

error
StorageError?

Error message.

示例


copy

Future<StorageResponse<StorageCopyResult>> storage.copy(
String fromPath,
String toPath, {
bool overwrite = true,
})

Copy file.

参数

fromPath
String

Source file path (relative path).

toPath
String

Target file path (relative path).

overwrite
bool

Whether to overwrite if target exists, default `true`.

返回

data
StorageCopyResult?

Copy result.

error
StorageError?

Error message.

示例


copyBatch

Future<StorageResponse<List<StorageCopyResult>>> storage.copyBatch(
List<Map<String, dynamic>> items,
)

Batch copy files.

参数

items
List<Map<String, dynamic>>

Copy item list, each item contains `srcPath` and `dstPath`.

返回

data
List<StorageCopyResult>?

Copy result list.

error
StorageError?

Error message.

示例


move

Future<StorageResponse<StorageCopyResult>> storage.move(
String fromPath,
String toPath, {
bool overwrite = true,
})

Move file (implemented by copy + removeOriginal).

参数

fromPath
String

Source file path (relative path).

toPath
String

Target file path (relative path).

overwrite
bool

Whether to overwrite if target exists, default `true`.

返回

data
StorageCopyResult?

Move result.

error
StorageError?

Error message.

示例


StorageUploadOptions

Upload options:

ParameterTypeDescription
cacheControlString?Cache control, e.g. max-age=3600
contentTypeString?File MIME type, e.g. image/jpeg
metadataMap<String, dynamic>?Custom metadata
upsertboolWhether to overwrite existing file, default true

StorageUploadResult

Upload result:

ParameterTypeDescription
idString?CloudBase fileID
pathString?Upload path
fullPathString?File full path

StorageUploadInfo

Upload info:

ParameterTypeDescription
pathString?File path
uploadUrlString?Upload URL
tokenString?Upload token
authorizationString?Upload authorization
fileIdString?File ID
cosFileIdString?COS file ID
codeString?Error code
messageString?Error message

StorageDownloadInfo

Download info:

ParameterTypeDescription
fileIdString?File ID
downloadUrlString?Download URL
codeString?Error code (on partial failure)
messageString?Error message (on partial failure)

StorageDeleteResult

Delete result:

ParameterTypeDescription
fileIdString?File ID
codeString?Error code (on partial failure)
messageString?Error message (on partial failure)

StorageCopyResult

Copy result:

ParameterTypeDescription
cloudObjectIdString?Cloud file ID of copied object
codeString?Error code (on partial failure)
messageString?Error message (on partial failure)

StorageResponse<T>

Storage response:

ParameterTypeDescription
dataT?Response data
errorStorageError?Error message

StorageError

Storage error:

ParameterTypeDescription
codeString?Error code
messageString?Error message
requestIdString?Request ID