Java (for Android and J2SE)
SDK source code: https://github.com/yandex-disk/yandex-disk-restapi-java
In addition to the library code, the SDK contains a sample application that implements several calls to the Yandex.Disk API, and code for testing it. The demo application requires Android version 4.0.3, but you can use the SDK with earlier OS versions.
Enabling the SDK
You can import the Maven project for using SDK calls in your app: http://mvnrepository.com/artifact/com.yandex.android/disk-restapi-sdk.
Authorization in Yandex.Disk
With Android, you can request an OAuth token using the API Account Manager — this feature is used in the sample app. If the necessary Yandex account is not on the phone, the app displays the oauth.yandex.ru web interface. The user must log in on Yandex in order to grant the app access to files on Yandex.Disk.
Actions with Yandex.Disk
To access Yandex.Disk, you must use a
RestClient class object.
All the Yandex.Disk functions supported by the SDK are implemented in the methods for this class:
- Get general information about Yandex.Disk —
- Get a flat list of all resources —
- Get a list of recently uploaded files —
- Get a list of published resources —
- Get metainformation about resources —
- Add metainformation for a resource —
- Create a folder —
- Delete a resource —
- Restore a resource from the Trash —
- Empty the Trash —
- Upload a file to Yandex.Disk —
- Download a file from Yandex.Disk —
- Save a file from the internet on Yandex.Disk —
- Download a public resource —
- Save a public resource on Yandex.Disk —
- Make a resource public —
- Close access to a resource —
- Get the status of an asynchronous operation —