Back

Exception: Invalid image data

  • 0
  • Flutter
mc-stephen
30 Sep, 2023, 22:34

If you click on the actual link to the img, does it show the img?

TL;DR
User is experiencing an exception related to invalid image data. They are discussing and seeking guidance on using a network image URL and calling a specific function. The conversation involves suggestions to check the code, use the Appwrite plugin for Flutter, and explore the Appwrite storage API. There is uncertainty about adding "mode=admin" to the URL and concerns about its safety. One user fixes the issue and asks if using "mode=admin" is correct. They also discuss the correct path for the image link. No solution is provided in the thread. Solution: It appears that the issue has been fixed by one user, but there is no explicit solution mentioned
Drake
30 Sep, 2023, 23:01

That is not the right path for the image. Thats the url of the image in the console, but not of the actual image itself

Hero
1 Oct, 2023, 06:52

This is a sample of the image link https://cloud.appwrite.io/v1/storage/buckets/$bucketId/files/$fileId/view?project=$projectId&mode=admin

This is the file path I see when I copy the image from the console.

Hero
1 Oct, 2023, 06:53

Do I need to append this line for the image file? 'view?project=$projectId&mode=admin'

Because that seems to be the only thing I am not passing but if I do that, isnt that kind of wrong?

Hero
1 Oct, 2023, 06:56

It opens the console as Stephen said, not the actual image. To open the actual image I need this link https://cloud.appwrite.io/v1/storage/buckets/$bucketId/files/$fileId/view?project=$projectId&mode=admin

But I am not sure appending mode=admin is safe.

Hero
1 Oct, 2023, 07:15

ok so I have fixed it @Steven and @mc-stephen but I want to find out if using the &mode=admin is right?

mc-stephen
1 Oct, 2023, 07:20

Not sure if it right, but certain it won't do anything wrong, tho I am not sure why u need to add that to the params before the img could show, I might have to look at the doc for that and get back to you latter in the day

Hero
1 Oct, 2023, 07:28

Alright. You could share the doc on this particular section as well so I check it out.

Drake
1 Oct, 2023, 17:37

Yes, this is the correct path. This is not what you had before. Also, in your client app, you shouldn't include mode=admin

Hero
1 Oct, 2023, 23:11

When I remove mode=admin it doesn't show though.

mc-stephen
1 Oct, 2023, 23:37

if you are not using an sdk for this then i will suggest you use the appwrite sdk for flutter that will help ease the stress, that way you can get any file hosted on your appwrite storage instant

mc-stephen
1 Oct, 2023, 23:37

this storage api should help you solve your issues => https://appwrite.io/docs/references/cloud/client-web/storage#getFile

mc-stephen
1 Oct, 2023, 23:37

if you can't, simple send a sample of your code here and i will help you debug it

Drake
1 Oct, 2023, 23:48

Is this a flutter web app?

mc-stephen
1 Oct, 2023, 23:56

i don't think it would make much diff if focus on web or mobile, but am certian it is a flutter project

mc-stephen
1 Oct, 2023, 23:57

don't really know why he his not using the appwrite pluggin for flutter

Drake
1 Oct, 2023, 23:59

For web, it could be a 3rd party cookie problem

mc-stephen
2 Oct, 2023, 00:01

since he said adding "mode=admin" make it works and not adding it does not, i don't really thinks it might be a cookie problem, that is why i suggested he share his code, he might be doing somthing wrong

Hero
2 Oct, 2023, 08:44

No, it is a flutter mobile app.

Hero
2 Oct, 2023, 08:45

I am using appwrite plugin.

Drake
2 Oct, 2023, 14:33

Oh wait. If you're using a url like this, the network image widget doesn't have the session so it will be making an unauthenticated request

Hero
2 Oct, 2023, 15:47

Seen @Steven but I am wondering at what point should I called createJwt()

Drake
2 Oct, 2023, 15:53

Up to you. Some time before you use the network image url

Hero
3 Oct, 2023, 08:53

Alright. Thanks.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more