[SOLVED] How to store image inside Appwrite bucket given by user in the file upload input field
- 0
- Databases
- Web
- Storage
Possible workflow, without function
- Upload file on bucket & get id of file
- Submit form with this reference
Let me try
Hi @Susmita , let us know if it doesn't
@Bouahaza's suggestion is perfect in my opinion.
Something I do, which is a tiny bit different from the suggestion is this:
- Have a bucket for all images
- Have an attribute in a collection for storing the appropriate file ID.
- When a user wants to upload an image that's only accessible by them, I execute a cloud function that takes the image and userID as an input. I then create a file in the bucket with permissions for that user only, and store the fileId in the document as needed.
It worked!!
But there's another issue now.
When images are previewed, they are of different sizes due to which UI is not looking good. How to fix that?
Are all the stored images the same size?
No
If they are, then this is weird. But if they're not the same size, then that's the intended way for this to work.
You can try resizing them on the client-side
Yeah, I tried but the problem is with the images which are small in size are even getting smaller and the bigger ones are getting to the perfect size of the card
What platform are you building on?
Next.js, Tailwind
Are you using next/image or the <img> tage?
next/image was giving some errors, so I'm using <img> tag
next/image has two props width and height that take in logical pixels. So if you pass in 100 for both of them, all images should be 100x100. If not perfect 100x100, they'll be close to it
Cuz i think next/image maintains the aspect ratio. not sure.
okay the <img> definitely is more flexible. Wrap the <img> with a div of your chosen size. Then make the <img> fill up the div
should work
let me try
sure
Solved
[SOLVED] How to store image inside Appwrite bucket given by user in the file upload input field
i had the same doubt regarding image upload. If you don't can you share any github repo to understand as an example. Or any code snippets. Thanks 😃
Recommended threads
- Getting CORS error when accessing websit...
When accessing my website I'm getting: (index):1 Access to font at 'https://assets.appwrite.io/fonts/inter/Inter-Regular.woff2' from origin 'https://mvp-site-ra...
- How to ByPass the Hostname restriction f...
Hello, Im hosting my React application in a stateless server environment, where the IP of the client keeps changing for the server. How do I bypass the hostname...
- Email templates partially broken in non-...
Good afternoon! Non-english locales are missing some variables introduced in recent releases. That makes the sent emails look bad. The issue has been raised a...