Back

HTTP 500 when listing bucket files

  • 0
  • Web
  • Storage
  • Cloud
Francisco "Klogan" Barros
19 Jan, 2025, 12:38

Appwriters πŸ‘‹ I'm trying to replace my Bunny CDN integration with appwrite storage buckets, but when trying to list files on a public bucket my Nuxt server receives a 500 error from the node-appwrite SDK.

I initially thought it could be an issue with my Query calls, but even after removing Queries and just passing the bucket ID, I'm still getting that 500. The AppwriteException that node-appwrite throws does not provide any information. Unfortunately.

Check my code snippet and my screenshots for more context.

TypeScript
  // Create Appwrite instance from Node SDK with API Key and Storage receiving Client
  const appwrite = useAppwriteNode().administrate().withStorage()

  try {
    const { projectName } = useAppwriteConfig()
    // The collection ID is 'Public' (I manually set human readable IDs on every bucket to avoid tracking UUIDs)
    const results = await appwrite.storage.listFiles(buckets.Public.id, [
      // Downgrading from the Pro plan limited maximum buckets, so I kind of "namespaced" my files (e.g., landing_*.jpg)
      Query.startsWith('name', buckets.Public.collections.Landing),
      Query.limit(10),
    ])

    return results.files.map((file) => ({
      src: generateFileUrl(buckets.Public.id, file.$id, projectName),
      // FIXME appwrite does not provide metadata about stored assets, hard-coding these values for the time being
      aspect: {
        w: 4,
        h: 5,
        ratio: 0.8,
      },
      orientation: 'portrait',
    }))
  } catch (e) {
    // This is the exception I'm getting on the breakpoint highlighted on screenshot
    console.error('Unable to list appwrite object storage files', e)

    return []
  }

I appreciate if you guys can give me pointers on what might be wrong.

Project ID: claymemoirs-development Bucket ID: Public

TL;DR
Developers are receiving a 500 error when listing bucket files using the `node-appwrite` SDK. Despite trying options like removing queries, the error persists. The issue could lie within the `listFiles` method. An exception is thrown without providing much information. Review code and screenshots for more context. Potential solution: Ensure the correct project ID (`claymemoirs-development`) and bucket ID (`Public`) are used in the code. Double-check the method being used from the `node-appwrite` SDK.
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