HUAWEI Driveのフォルダの種類
- ユーザーに見える普通のフォルダ
- ユーザーに見えないアプリケーションフォルダ(隠しフォルダ)
上記の2種類あります。
HUAWEI Driveのフォルダの作成手順
- HUAWEI Driveに接続する
- com.huawei.cloud.services.drive.model.Fileオブジェクトを生成する(フォルダはファイルの一種)
- com.huawei.cloud.services.drive.model.FileオブジェクトをHUAWEI Driveに渡して、実行する
注意点
1. mimeTypeに"application/vnd.huawei-apps.folder"をセットする
2. アプリケーションフォルダの場合、親フォルダのパラメータに{"applicationData"}をセットする
サンプル
private var drive: Drive? = null
fun createFolder(folderName: String, isApplicationFolder: Boolean): com.huawei.cloud.services.drive.model.File? {
drive?.let { drive ->
val appProperties: Map<String, String> = mutableMapOf("appProperties" to "property")
val file = com.huawei.cloud.services.drive.model.File()
.setFileName(folderName)
.setMimeType("application/vnd.huawei-apps.folder")
.setAppSettings(appProperties).apply {
if (isApplicationFolder) {
parentFolder = listOf("applicationData")
}
}
return drive.files().create(file).execute()
}
return null
}
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/