You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中使用Dio包上传Vimeo视频存在10%失败率问题排查

Flutter中Dio上传视频至Vimeo的稳定性问题
  • 在Flutter应用中使用Dio包通过POST方法上传视频至Vimeo,流程为先获取上传链接再执行上传,大部分场景下上传成功,但存在约1/10的失败率。
  • 为排查是否是Vimeo服务器问题,使用Postman测试20次上传均成功,因此怀疑问题出在Dio包,已在Dio的GitHub仓库提交相关Issue。

上传视频代码

if (url != null) {
    print('upload link is not null!');
    Strings.videoURL = url;
    print('upload url is <>');
    print(Strings.videoURL);
    try {
      Dio uploadVideoDio = new Dio();
      uploadVideoDio.options.headers["authorization"] = dotenv.env['VIMEO_ACCESS_TOKEN'];
      uploadVideoDio.options.headers["content-type"] = "application/json";
      uploadVideoDio.options.headers["accept"] = "application/json";

      var formData = FormData.fromMap({
        "file_data": await MultipartFile.fromFile(file.path)
      });

     await uploadVideoDio.post(
        Strings.videoURL,
        data: formData,
        options: Options(
            followRedirects: false,
            responseType: ResponseType.json,
            validateStatus: (status) {
              print('status is :');
              print(status);
              // return status! < 500;
              if (status == 302) {
                uploadStatus = 'successful';
                return true;
              } else {
                return false;
              }
            }),
      );
      print('file upload called');
      print('upload status is ');
      print(uploadStatus);
      return uploadStatus;
    } on DioError catch (err) {
      print('error uploading actual video');
      print(err.toString());
      return uploadStatus;
    }
  } else {
    print('upload link is null');
    return uploadStatus;
  }

后续更新

已联系Vimeo支持团队,对方正在排查问题,回复称POST上传方法不够可靠,建议使用TUS可恢复上传方案,即将测试该方案的稳定性并后续更新。

内容的提问来源于stack exchange,提问作者Manas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 05:45:40