
Heyo.
Using expo-imagepicker (https://docs.expo.dev/versions/latest/sdk/imagepicker/), I am trying to upload a file to appwrite, however it seems that it keeps saying "undefined" on the console.log(storageData)
. What am I missing?
It also does not upload the image.
Picking the image:
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
})
if (!result.canceled) {
const image = result.assets[0]
const maxResolution = 5000 * 5000
const maxFileSize = 8 * 1024 * 1024 // 4MB in bytes
if (image.width * image.height > maxResolution) {
toast('Image resolution is too large')
}
if (image.fileSize > maxFileSize) {
toast('Image file size is too large')
}
if (
image.width * image.height <= maxResolution &&
image.fileSize <= maxFileSize
) {
setImage(image.uri)
setPage(2)
}
}
}
Here's the function:
async function uploadImageAsync() {
if (!image) {
toast('Please select an image to upload')
return
}
if (!title || title.length <= 3) {
toast('Please provide a valid title.')
return
}
try {
//setUploading(true)
const storageData = await storage.createFile(
'gallery',
ID.unique(),
image,
[],
(event) => setProgress(event.progress)
)
console.log(storageData)
await database.createDocument(
'hp_db',
'gallery-images',
storageData.$id,
{
name: title,
longText: description,
nsfw: nsfw,
userId: current.userId,
}
)
} catch (error) {
setUploading(false)
console.error(error)
}
}

Storage file not uploading - React native
Recommended threads
- User Authentication through REST API
Hey everyone, I’m looking for some guidance on the best way to authenticate frontend requests to my API gateway using Appwrite sessions. Right now, I'm trying ...
- Custom domain issue
Hello following another post I'm creating dedicated post according to my project ID: 67ffbd800010958ae104 I deployed for debug my React Native app in web, chrom...
- Constant 404 Pages
Whenever I am navigating through items and pages to go through my collections and database I end up at a page that sends me a 404 error, if i refresh it remains...
