Drive KitでHUAWEI Driveからファイルをダウンロードする方法
HUAWEI Driveからのダウンロード手順
- HUAWEI Driveに接続する
- ファイルオブジェクトを取得する
- HUAWEI Driveのダウンロードリクエストを実行する
注意点
1. ファイルサイズが20MB以下の場合、isDirectDownloadEnabledをtrueに設定できます。
サンプル
private var drive: Drive? = null
fun load(filename: String, dest: File, isApplicationData: Boolean) {
getFile(filename, false, isApplicationData)?.let { file ->
download(file, dest)
}
}
private fun download(file: com.huawei.cloud.services.drive.model.File, dest: File) {
drive?.let { drive ->
val size: Long = file.getSize()
val isDirectDownload = file.getSize() < DIRECT_DOWNLOAD_MAX_SIZE
drive.files()[file.id].let { get ->
get.mediaHttpDownloader.setContentRange(0, size - 1).isDirectDownloadEnabled = isDirectDownload
get.executeContentAndDownloadTo(FileOutputStream(dest))
}
}
}
GitHub
HMS Drive Kit Demo : https://github.com/Rei2020GitHub/MyPublicProject/tree/master/DriveKitDemo
参考
- HMS:https://developer.huawei.com/consumer/jp/
- HMS Drive Kitの紹介:https://developer.huawei.com/consumer/jp/hms/huawei-drivekit
- HMS Drive Kitのドキュメント:https://developer.huawei.com/consumer/jp/doc/development/HMSCore-Guides/introduction-0000001050039630
- Huawei Developers:https://forums.developer.huawei.com/forumPortal/en/home
- Facebook Huawei Developersグループ:https://www.facebook.com/Huaweidevs/
Author And Source
この問題について(Drive KitでHUAWEI Driveからファイルをダウンロードする方法), 我々は、より多くの情報をここで見つけました https://qiita.com/Rei_2020/items/c11fd88f9d74392d455f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .