最近用flutter开发IM软件,用到腾讯云上传图片视频等资源,发现居然没有改插件,于是动动手自己写了个iOS和安卓的
Android 接入腾讯云上传工具,iOS在另一文章中有详细记载,有问题可以留言
/**
* 腾讯云
*/
public class Plugin implements MethodCallHandler {
Registrar registrar;
MethodChannel channel;
public TencentCosPlugin(Registrar registrar, MethodChannel channel) {
this.registrar = registrar;
this.channel = channel;
}
/**
* Plugin registration.
*/
public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "tencent_cos");
channel.setMethodCallHandler(new TencentCosPlugin(registrar, channel));
}
@Override
public void onMethodCall(MethodCall call, final Result result) {
if (call.method.equals("TencentCos.uploadFile")) {
LocalSessionCredentialProvider localCredentialProvider = new LocalSessionCredentialProvider(call.<String&