Release Notes
Announcements
<uses-permission android:name="android.permission.INTERNET"/>
voduploadadv project locally and use a relative path for dependency.voduploadadv:path: ../voduploadadv/
flutter cleanflutter pub get
secretId, secretKey, token, and expiredTime when needed by the SDK.TxVodUploadPlugin.instance.initWithScopeLimitCredential((stsCredentialScopes) async {// Recommended: Fetch credentials from your serverMap<String, dynamic> jsonMap = jsonDecode(testRsCre);Map<String, dynamic> resJsonMap = jsonMap["Response"];Map<String, dynamic> credentialsJsonMap = resJsonMap["Credentials"];int expiredTimeStamp = DateTime.parse(credentialsJsonMap['Expiration']).millisecondsSinceEpoch;return FTXSessionQCloudCredentials(secretId: credentialsJsonMap["AccessKeyId"],secretKey: credentialsJsonMap["SecretAccessKey"],token: credentialsJsonMap["SessionToken"],expiredTime: expiredTimeStamp);});
stsCredentialScopes parameter includes:// Simple upload"name/cos:PutObject",// Form upload"name/cos:PostObject",// Multipart upload: Initiate"name/cos:InitiateMultipartUpload",// Multipart upload: List ongoing"name/cos:ListMultipartUploads",// Multipart upload: List uploaded parts"name/cos:ListParts",// Multipart upload: Upload part"name/cos:UploadPart",// Multipart upload: Complete"name/cos:CompleteMultipartUpload",// Multipart upload: Abort"name/cos:AbortMultipartUpload"
TXUploader, there are two modes: subApp and bucket, corresponding to the automatic mode and the specified bucket mode respectively.TXUploader.bucketMode and TXUploader.autoMode respectively. In addition, you also need to pass in your sub-application ID. The sample code is as follows:_uploader = TXUploader.bucketMode(0000000000, "xxxxxxxxxxxxx");
_uploader?.setUploadCallback = FTXUploadCallback(successCallBack: (header, result) async {// Upload success! Access file URL via result.accessUrl},failCallBack: (clientException, serviceException) async {// Handle upload failure},progressCallBack: (complete, target) {// Progress: 'complete' = bytes uploaded, 'target' = total bytes},stateCallBack:(state) {// State change notification},startUploadCallback: (bucket, cosKey, uploadId) async {// Upload started! Store 'uploadId' for resuming later});
UploadConfig uploadConfig = UploadConfig();uploadConfig.sliceSizeForUpload = 1024 * 1024 * 2; // Default: 2MB slice size (adjustable)uploadConfig.isHttps = true; // Use HTTPS (default: true)uploadConfig.enableVerification = true; // Enable slice verification (default: true)
Parameter | Description |
localFilePath | Local file path (required). |
fileKey | Filename on server (required). |
uploadId | Resume upload using previous ID (optional). |
uploadConfig | Upload settings (optional). |
int? code = await _uploader?.upload(params);if (code == TXUploadCode.TX_UPLOAD_OK) {showResult("Upload started");} else {showResult("Upload failed with code $code");}
TXUploadCode.TX_UPLOAD_OK: Success.TXUploadCode.TX_UPLOAD_BUSY: Uploader busy.TX_FILE_NOT_FOUND: Invalid file path.Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback