Unable to Upload images via Stream Feeds

102 Views Asked by At

I'm using GetStream Feeds and stream_feed_flutter_core for building a instagram like app. I'm able to add activity to the feeds and even able to upload files but not able to upload images.

Steps I'm following for setting up the client and user:

  1. final client = StreamFeedClient("apiKey", logLevel: Level.INFO);
  2. final currentUser = await client.setUser( User( id: user2Id, data: {"name": user1Name, "profile_image": user2Image}), Token(token_2));

Steps for uploading the images:

  1. Pick an image from gallery as XFile pickedFile
  2. uploadImage() async{ var imageUrl = await context.feedClient.images.upload(AttachmentFile(path: pickedFile.path)); }

Stream API response:

{
  "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"
}
1

There are 1 best solutions below

0
On

are you able to setUser? what do you get the context.feedClient

In my case it is working fine

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)
    }