Edit file using the Android SAF(storage access framework)
I'm trying to edit box files using the android SAF picker. When choosing a file for edit I'm checking a write availability, which is granted, and then then im trying to write to the file but getting an internal exception:
java.io.FileNotFoundException: Attempt to invoke virtual method 'java.lang.String java.io.File.getPath()' on a null object reference
2020-02-23 17:40:26.371 29269-29269/com.example.editinplaceplayground W/System.err: at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:149)
2020-02-23 17:40:26.371 29269-29269/com.example.editinplaceplayground W/System.err: at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:631)
2020-02-23 17:40:26.371 29269-29269/com.example.editinplaceplayground W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1521)
2020-02-23 17:40:26.371 29269-29269/com.example.editinplaceplayground W/System.err: at android.content.ContentResolver.openOutputStream(ContentResolver.java:1227)
2020-02-23 17:40:26.371 29269-29269/com.example.editinplaceplayground W/System.err: at android.content.ContentResolver.openOutputStream(ContentResolver.java:1203)
Using the same code to edit a file that opened directly from the box app is working.
-
Hi ,
Can you supply the code that you're using to access Box? It might help to dig down deeper. From the error this looks like an Android SAF issue rather than Box, so it may be best to reach out via their forums with the inquiry, since the same code works with files loaded directly in Box.
A few shots in the dark to take a look at though:
- Similar errors were reported with image consumption, and switching from getting file by path to opening an input stream seemed to solve the problem - SO thread here.
- Ensure that the Box access token that you're using has write access to the file. I'm not sure how you're verifying this currently but a common problem when accessing files from Box is using an access token that's scoped for a user (e.g. a service account) that doesn't have appropriate permission to that file. For instance, it may have read access but not write.
- If you're using a Box app, verify that you have all appropriate read / write scopes enabled.
We can dig in deeper with additional detail / code if none of the above works, as they're all stabs in the dark.
サインインしてコメントを残してください。
コメント
1件のコメント