Back

Error 404 when trying to createFile in storage

  • 0
  • Self Hosted
  • Android
  • Storage
jj_mad
8 Oct, 2024, 09:49

I have just came across this error, I am doing a migration using an android app. I successfully manage to create other files but with this one I am getting this error: Code is the following:

TypeScript
 suspend fun uploadAttachment(
      file: InputFile,
      fileId: String,
      permissions: List<String>,
      ignoreAlreadyExists: Boolean = false
  ): File? {
      try {
          return storage.createFile(
              bucketId = ATTACHMENTS_BUCKET_ID,
              fileId = fileId,
              file = file,
              permissions = permissions
          )
      } catch (e: AppwriteException){
          if (e.type == "general_unauthorized_scope"){
              // User is not log in or not enough permission
              onAutomaticLogin()
              return uploadAttachment(
                  file,
                  fileId,
                  permissions
              )
          // In case the document exists and ignore is true: do not throw
          // Throw on the rest of the cases
          } else if (e.type != "document_already_exists" || !ignoreAlreadyExists){
              throw e
          } else {
              //The file already exists so return null
              return null
          }
      }
  }

The error that I get with around 100 files of 2.000 is io.appwrite.exceptions.AppwriteException: The requested file could not be found. Error 404

I manually check in the local storage and files exists and I can open them and view their content. So I am not really sure why this problem. As I mentioned before, code is working for other.

I have checked the sdk to see what may cause the problem and the problem is in this block when doing the GET call in the Client.kt (line 400)

When the call is made using POST (line 382 in the same file), file is successfully uploaded

Thank you in advance for your time

TL;DR
Error 404 (file not found) when trying to create a file in storage using an Android app. The issue might be with the GET call in Client.kt. Files exist locally. Uploading works with POST, but not with GET.
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