Back

AppwriteException: Missing required parameter: "fileId"

  • 0
  • Web
dantedmc
24 Mar, 2024, 23:31

Sorry everyone but I got a problem SERVICE

TypeScript
        return this.storage.getFilePreview(
            conf.appwriteBucketId,
            fileId
        )
    }```

**Not working in my post form**
```        {post && (
          <div className='w-full mb-4'>
            <img 
            src={appwriteService.getFilePreview(post.blogImage)}
            alt={post.title} 
            className='rounded-lg'
            />
          </div>
        )}```

**Not working in my Home page**
```            <div>
                {!blogImage? null: <div>
                    <img src={appwriteService.getFilePreview(blogImage)} alt={title}/>
                </div> }
                <div'>
                    <div>{title}</div>
                </div>
            </div>```
**Not working in my blog page**(When I visit blog page it says missing parameter 'fileId')
```<img
            src={appwriteService.getFilePreview(post.blogImage)}
            alt={post.title}
            className='rounded-xl'
          />```
TL;DR
AppwriteException error: Missing required parameter 'fileId' pops up in blog page, while home and post form pages lack image preview functionality. Trouble lies in missing 'fileId' when passing it to 'getFilePreview'. Developers should log 'fileId' before passing it and check inputs/outputs/variables.
dantedmc
24 Mar, 2024, 23:32

This is where I assign fileId

TypeScript
        try {
          const file = await appwriteService.uploadFile(data.image[0]);     
          if (file) {
              const fileId = file.$id
              data.blogImage = fileId
              console.log(`blogImage`, fileId)
              const dbPost = await appwriteService.createPost({
                ...data,
                userId: userData.$id})

              if (dbPost) {
                navigate('/profile')
              }
          }
        } catch (error) {
          console.log(`ERROR POSTING `, error)
        }
      
      }```
dantedmc
24 Mar, 2024, 23:32

Please help

Steven
24 Mar, 2024, 23:34

Did you try logging fileId before passing it into storage.getFilePreview()?

Steven
24 Mar, 2024, 23:36

As with everything, troubleshoot by working your way back, making sure inputs/outputs/variables are what you expect them to be

dantedmc
24 Mar, 2024, 23:37

Yes I did and it shows correct data

Steven
24 Mar, 2024, 23:37

But you're getting an error saying fileId is missing?

dantedmc
24 Mar, 2024, 23:37

yes

Steven
24 Mar, 2024, 23:38

Also, instead of saying something is not working, it's better to be explicit and say what is going on

dantedmc
24 Mar, 2024, 23:38

sure

dantedmc
24 Mar, 2024, 23:39

AppwriteException: Missing required parameter: "fileId"

dantedmc
24 Mar, 2024, 23:41

In my home page I am not getting any error but I cannot preview the image same case with post form page but in my blog page it is showing that AppwriteException: Missing required parameter: "fileId"

Steven
24 Mar, 2024, 23:42

Sounds like you have two different problems

dantedmc
24 Mar, 2024, 23:44

yes

Steven
24 Mar, 2024, 23:45

Focus on the file id error in this support thread

Steven
24 Mar, 2024, 23:46

For your other one, search support for similar problems and 3rd party cookies

dantedmc
24 Mar, 2024, 23:46

sure

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