dart 无法通过流源上传图像

vsnjm48y  于 2023-06-27  发布在  其他
关注(0)|答案(1)|浏览(101)

我正在使用GetStream Feeds和stream_feed_flutter_core来构建一个类似Instagram的应用程序。我能够添加活动的饲料,甚至能够上传文件,但不能上传图像。
下面是设置客户端和用户的步骤:

  1. final client = StreamFeedClient("apiKey", logLevel: Level.INFO);
  2. final currentUser = await client.setUser(User(id:user 2 Id,数据:{“name”:user1Name,“profile_image”:user2Image}),Token_2));
    上传图片的步骤:
    1.从图库中选取一个图像作为XFile pickedFile
  3. uploadImage()async{ var imageUrl = await context.feedClient.images.upload(AttachmentFile(path:pickedFile.path);}
    流API响应:
{
  "detail":"token contains an invalid number of segments",
  "status_code":403,
  "code":17,
  "exception":"NotAllowedException",
  "duration":"0.00ms",
  "more_info":"https://getstream.io/docs/api_error_responses"
}
7vux5j2d

7vux5j2d1#

你能做setUser吗?什么是context.feedClient
在我的情况下,它工作得很好

this.client = connect(API_KEY, this.userToken, APP_ID)

  async uploadImage (file) {
    return new Promise((resolve, reject) =>
      (async () => {
        try {
          const imgSrc = await this.client.images.upload(file)
          resolve(imgSrc)
        } catch (err) {
          reject(err)
        }
      })()
    )
  }

const uploadImageSrc = async e => {
    const image = e.target.files[0]
    uploadImage(image)
    }

如果这是有帮助的,请投赞成票和喜欢,谢谢。

相关问题