2022-11-23 08:19:43 +13:00
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
|
import android.os.Bundle
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import io.appwrite.Client
|
|
|
|
import io.appwrite.services.Storage
|
2022-11-17 12:35:44 +13:00
|
|
|
|
2022-11-23 08:19:43 +13:00
|
|
|
public class MainActivity extends AppCompatActivity {
|
2022-11-17 12:35:44 +13:00
|
|
|
|
2022-11-23 08:19:43 +13:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_main);
|
2022-11-17 12:35:44 +13:00
|
|
|
|
2022-11-23 08:19:43 +13:00
|
|
|
Client client = new Client(getApplicationContext())
|
|
|
|
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
|
|
|
|
.setProject("5df5acd0d48c2"); // Your project ID
|
2022-11-17 12:35:44 +13:00
|
|
|
|
2022-11-23 08:19:43 +13:00
|
|
|
Storage storage = new Storage(client);
|
|
|
|
|
|
|
|
storage.deleteFile(
|
|
|
|
"[BUCKET_ID]",
|
|
|
|
"[FILE_ID]"
|
|
|
|
new Continuation<Object>() {
|
|
|
|
@NotNull
|
|
|
|
@Override
|
|
|
|
public CoroutineContext getContext() {
|
|
|
|
return EmptyCoroutineContext.INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resumeWith(@NotNull Object o) {
|
|
|
|
String json = "";
|
|
|
|
try {
|
|
|
|
if (o instanceof Result.Failure) {
|
|
|
|
Result.Failure failure = (Result.Failure) o;
|
|
|
|
throw failure.exception;
|
|
|
|
} else {
|
|
|
|
Response response = (Response) o;
|
|
|
|
json = response.body().string();
|
|
|
|
}
|
|
|
|
} catch (Throwable th) {
|
|
|
|
Log.e("ERROR", th.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|