File Upload of ByteArray Failing with Resource Not Found

API ID: 8149FCCE-07DA-F988-FFBB-6154872C9500

Hello, I’m calling saveFile from the JS File API passing a valid directory, a valid file name, and what looks to be a valid Blob (looks like a valid base64-encoded string) using code that’s been working for a long time. Suddenly I’m getting a “6007, Resource Was Not Found” error consistently. What resource could be missing in a file save? The output directory is definitely there, and permissions look OK. It’s apparent from my log files that it started yesterday.

Thanks,
Kelly

I can’t upload files from byte streams. I AM able to upload files using the Upload button in the console. I’ve tried everything I can think of. I thought maybe cleaning out unneeded files might make a difference. However, deleting files in the console failed with the following. Perhaps it pertains??:

Application ID: `8149FCCE-07DA-F988-FFBB-6154872C9500`
Error UID: `DD8979E3-86E7-7313-FFAD-D50CC7B44E00`

Backendless encountered an error while handling the request. An internal trouble ticket with ID DD8979E3-86E7-7313-FFAD-D50CC7B44E00 has been created and we will be investigating the issue.
org.hibernate.exception.LockAcquisitionException: could not execute statement
javax.persistence.OptimisticLockException: org.hibernate.exception.LockAcquisitionException: could not execute statement
	at org.hibernate.internal.ExceptionConverterImpl.wrapLockException(ExceptionConverterImpl.java:277)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:98)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
	at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1705)
	at com.backendless.datamodel.application.dao.FileUserPermissionDao.lambda$deleteByResourceId$0(FileUserPermissionDao.java:31)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.executeSync(AppJpaTransaction.java:134)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.executeSync(AppJpaTransaction.java:203)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.execute(AppJpaTransaction.java:54)
	at com.backendless.datamodel.application.dao.FileUserPermissionDao.deleteByResourceId(FileUserPermissionDao.java:28)
	at com.backendless.services.file.internal.FileService.lambda$deleteFileOrDirectory$12(FileService.java:1087)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.lambda$execute$1(AppJpaTransaction.java:72)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.executeSync(AppJpaTransaction.java:134)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.executeSync(AppJpaTransaction.java:203)
	at com.backendless.datamodel.application.dao.AppJpaTransaction.lambda$execute$0(AppJpaTransaction.java:46)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
	Suppressed: java.util.concurrent.ExecutionException: javax.persistence.OptimisticLockException: org.hibernate.exception.LockAcquisitionException: could not execute statement
		at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
		at java.base/java.util.concurrent.

To rule out inadvertent code changes, I abstracted a simple example away from my failing app. The simple example below fails in the same way. I don’t think this problem is on my end. The resource the error is complaining about is the app-files directory. The example works when writing to any directory under root except app-files. Clearly, that is a valid subdirectory, so I’m baffled. And, the file is actually created, yet the function throws the 6007 error regardless. I’m still down, because even though the file is created, no URL is returned, so the error still crashes my app. The JS SDK version is 6.5.5.

image

    let welcome = new Uint8Array([87, 101, 108, 99, 111, 109, 101]);
    let blob = new Blob([welcome, ' to ', 'backendless'], {type: 'text/plain'});                
    let backendless = this.$db.getObject()
    backendless.Files.saveFile('/app-files', '000aaa.txt', blob, false)
    .then(res => {
        console.log(res)
    })
    .catch(error => {
        console.log(error)
    })

Results in:

Error: The specified resource was not found
    at new ResponseError (backendless.js?b8b6:1105:1)
    at checkStatus (backendless.js?b8b6:1300:1)

Hi @Kelly_Oglesby ,

Just tried your code in my test app and was unable to reproduce your problem. Also tried to use your code to upload test file to test directory in your app. It also went without any problems.

The only difference between your and mine code was in this lines

let backendless = this.$db.getObject()
backendless.Files.saveFile('/app-files', '000aaa.txt', blob, false)

Ir gave me an error so I used next code instead

Backendless.Files.saveFile('/test', '000aaa.txt', blob, false)

Could you please try to change those lines in your code and try one more time to upload test file?

Regards, Andriy

All Backendless calls now return this - is this you?

400 - Failed to run code in sandbox on behalf of application's system user.

Hi, @Kelly_Oglesby

We are sorry for the inconvenience. Our team is working on it. This problem is of the highest priority for us.

Regards,
Marina

@Kelly_Oglesby, The issue that you wrote about above has been fixed from our side. Can you confirm that everything is working as it should now?

Regards,
Marina

Yes, it is back up, thank you. I’ll provide the info Andriy requested soon. So, how is your day going?

:>)

Whatever was wrong with that directory over the last 5 days is now corrected. I can no longer reproduce the error. Thank you all!