
I created a bucket from console and connected my project to appwrite SDK etc. Now I am trying to send file(s) from mobile External Dir to storage.
// push to clould func
public void cloudStorage() {
String endPoint = "*****"
String setProject = "*****"
String apiKey = "*****"
String bucketID = "*****"
Client client = new Client(requireActivity());
client.setEndpoint(endpoint);
client.setProject(project);
client.setSelfSigned(true);
File file = new File(Objects.requireNonNull(requireContext().getExternalFilesDir(null).getParent())); //externaldir path
Storage storage = new Storage(client);
storage.createFile(
bucketID,
file,
InputFile.Companion.fromPath("FILE.xls"),
new CoroutineCallback<>(result, error) ->{
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
}
}
So when trying to use CoroutineCallback can =not resolve symbool 'result' & 'error' which are supposed to be the object
and error
handler.
after a deep research, I noticed CoroutineCallback is a class in appwrite SDK for kotlin .
Pls help me know how i can handle this task with android JAVA SDK.

CoroutineCallback
can be used with the Java SDK for appwrite as well.
To address your error - can =not resolve symbool 'result' & 'error'
- it looks a small mistake in your syntax.
Your code:
storage.createFile(
bucketID,
file,
InputFile.Companion.fromPath("FILE.xls"),
new CoroutineCallback<>(result, error) ->{
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
}
Fixed code:
storage.createFile(
bucketID,
file,
InputFile.Companion.fromPath("FILE.xls"),
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}
Log.d("Appwrite", result.toString());
})
);

You seem to have missed a couple of parentheses. Especially the ones for the CoroutineCallback
. Instead of CoroutineCallback<>(result, error) -> {}
, you need to do CoroutineCallback<>((result, error) -> {})
Hope this makes sense.

Feel free to ask any questions if this doesn't work

Thanks that worked. I was careless with the syntax. I am new to this server. How can i close this question or mark Solved.

Not an issue, happens to the best of us!

To mark the question as solved, just edit the post title to [SOLVED] Storage API. Android SDK(java)

[SOLVED]Storage API. Android SDK(java)
Recommended threads
- Query params are way too limiting in ter...
I was trying to list rows in a table that do not already exist in another table. I retrieved around 260 row IDs which are 13 characters in length each, and then...
- Relationship null, even when relationshi...
Hi Everyone, im experiencing issues with set relation data. When im setting the document id from the related database most of them seem fine, except one table. ...
- REQUEST FAILED IN MIGRATION
I was trying to moved my archived project to a self-host database . Though the Project is "read only" but there's a message that I can view and migrate data to...
