Back

Error when uploading the file

  • 1
  • Flutter
  • Cloud
Raman
8 Feb, 2025, 12:41

Error uploading document: AppwriteException: document_invalid_structure, Invalid document structure: Unknown attribute: "id" (400)

The file is successfully uploaded but throwing the above error

TL;DR
Developers are experiencing an error when uploading a file, receiving the message "Error uploading document: AppwriteException: document_invalid_structure, Invalid document structure: Unknown attribute: 'id' (400)." The error is related to a prefixed internal `id`. The code snippet provided appears to be correct. The issue seems isolated to the API, as uploading via the console works fine. The SDK version is requested. Potential Solution: - Check and ensure the `id` attribute is being handled correctly. - Verify the SDK version being used. - Attempt to reproduce the issue within the console. - Share a snippet of how the file is being uploaded
Raman
8 Feb, 2025, 12:41

cc: @Darshan Pandya

Darshan Pandya
8 Feb, 2025, 12:42

how are you uploading the file, maybe share a snippet as well?

Darshan Pandya
8 Feb, 2025, 12:42

is this reproducible via console as well?

Raman
8 Feb, 2025, 12:44

Okay

Raman
8 Feb, 2025, 12:45
TypeScript
final file = await _storage.createFile(
        bucketId: _bucketId,
        fileId: ID.unique(),
        file: InputFile.fromBytes(
          bytes: fileData,
          filename: name,
          contentType: 'application/octet-stream',
        ),
        // permissions: [
        //   Permission.read(Role.any()),
        //   Permission.write(Role.any()),
        // ],
      );
Darshan Pandya
8 Feb, 2025, 12:53

code looks OK, what sdk version?

Darshan Pandya
8 Feb, 2025, 12:53

upload on console works fine so its not the API bug on Cloud.

Darshan Pandya
8 Feb, 2025, 12:54

are you making any database calls too? maybe somewhere else in parallel?

Darshan Pandya
8 Feb, 2025, 12:57

the internal ids are always prefixed with $.

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