Skip to content

A library for simply uploading files to Alibaba Cloud Object Storage OSS.

License

Notifications You must be signed in to change notification settings

biner88/upload_file_oss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

upload_file_oss

Pub

一个简单上传文件到阿里云对象存储OSS的库。 仅支持小文件上传。

安装

pub.dev Install

引入文件

import 'package:upload_file_oss/upload_file_oss.dart';

使用

详细见 example/lib/main.dart

 final UploadFileOSSClient client = UploadFileOSSClient(
    UploadFileOSSConfig(
      accessKeyId: '',
      accessKeySecret: '',
      endpoint: 'oss-cn-hangzhou.aliyuncs.com',
      bucket: '',
      fileDomain: '',
    ),
  );

  ///本地文件路径
  final String localFilePath = '/Users/xx.png';

  ///Object 存在OSS上的文件路径
  final String savePath = 'avatar/me.jpg';

  ///读取本地的文件,并转换为Uint8List
  final File file = File(localFilePath);
  final Uint8List fileContent = await file.readAsBytes();

  ///执行上传到 OSS
  Map res = await client.putObject(
    savePath,
    fileContent,
    overwrite: false,
  );
  print(res);

上传返回

上传成功返回

  {
    "statusCode": 200, 
    "size": 3506, 
    "downloadUrl": "https://yourbucket.oss-cn-hangzhou.aliyuncs.com/avatar/me.jpg", 
    "url": "https://yourfiledomain/avatar/me.jpg",
  }

上传失败返回

  {
    "statusCode": 4xx, 
    "size": 0, 
    "downloadUrl": "", 
    "url": "",
  }

About

A library for simply uploading files to Alibaba Cloud Object Storage OSS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages