This plugin was created based on Huawei Drive Kit. Please Drive Kit for detailed information.
In order to use this plugin, you must first create an account from developer.huawei.com. And after logging in with your account, you must create a project in the huawei console in order to use HMS kits.
To use the plugin please add following to build.settings
{
plugins = {
["plugin.huaweiDriveKit"] = {
publisherId = "com.solar2d",
},
},
}
And then you have to create keystore for your app. And you must generate sha-256 bit fingerprint from this keystore using the command here. You have to define this fingerprint to your project on the huawei console.
And you must add the keystore you created while building your project.
Also you need to give the package-name of the project you created on Huawei Console.
And you need to put agconnect-services.json
file into main.lua
directory.
After all the configuration processes, you must define the plugin in main.lua.
local huaweiDriveKit = require "plugin.huaweiDriveKit"
local function listener(event)
print(event)
end
huaweiDriveKit.init(listener, {unionId="xxxx", accessToken="xxxx"}, function(event)
print(json.prettify( event ))
end) -- sets listener and inits plugin
As you can see above, you we can get result of methods with listener method.
Call the createDirectory method to create a directory.
library.createDirectory({dirName="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = createDirectory (text)
provider = DriveKit (text)
data = Directory(json)
}
]]--
Call the updateFile method to update file or folder.
library.updateFile({fileId="xxxx", newFilePath="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = updateFile (text)
provider = DriveKit (text)
}
]]--
Call the deleteFile method to delete a file or folder permanently.
library.deleteFile({fileId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = deleteFile (text)
provider = DriveKit (text)
}
]]--
Call the downLoadFile method to delete a file or folder permanently.
library.downloadFile({fileId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = downloadFile (text)
provider = DriveKit (text)
}
]]--
Call the getFileList method to search for files.
library.getFileList({query="xxxx", orderBy="xxxx", fields="xxxx", pageSize=2}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = getFileList (text)
provider = DriveKit (text)
data = Files (jsonArray)
}
]]--
Call the createComments method to create a comment.
library.createDirectory({fileId="xxxx", description="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = createComments (text)
provider = DriveKit (text)
data = Comment(json)
}
]]--
Call the listComments method to list comments.
library.listComments({fileId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = listComments (text)
provider = DriveKit (text)
data = Comments(jsonArray)
}
]]--
Call the getComments method to obtain comment details.
library.getComments({fileId="xxxx", commentId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = getComments (text)
provider = DriveKit (text)
data = Comment(json)
}
]]--
Call the updateComments method to update a comment.
library.updateComments({fileId="xxxx", commentId="xxxx", description="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = updateComments (text)
provider = DriveKit (text)
}
]]--
Call the deleteComments method to obtain comment details.
library.deleteComments({fileId="xxxx", commentId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = deleteComments (text)
provider = DriveKit (text)
}
]]--
Call the createReplies method to create a reply.
library.createReplies({fileId="xxxx", description="xxxx", description="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = createReplies (text)
provider = DriveKit (text)
data = Reply(json)
}
]]--
Call the listReplies method to list replies.
library.listReplies({fileId="xxxx", commentId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = listReplies (text)
provider = DriveKit (text)
data = Replies(jsonArray)
}
]]--
Call the getReplies method to obtain reply details.
library.getReplies({fileId="xxxx", commentId="xxxx", replyId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = getReplies (text)
provider = DriveKit (text)
data = Reply(json)
}
]]--
Call the updateReplies method to update a reply.
library.updateReplies({fileId="xxxx", commentId="xxxx", description="xxxx", description="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = updateReplies (text)
provider = DriveKit (text)
}
]]--
Call the deleteReplies method to obtain comment details.
library.deleteReplies({fileId="xxxx", commentId="xxxx", replyId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = deleteReplies (text)
provider = DriveKit (text)
}
]]--
Call the listHistoryVersions method to list the historical versions of a file.
library.listHistoryVersions({fileId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = listHistoryVersions (text)
provider = DriveKit (text)
data = HistoryVersionList(json)
}
]]--
Call the getHistoryVersions method to obtain the historical version details of a file.
library.getHistoryVersions({fileId="xxxx", historyVersionId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = getHistoryVersions (text)
provider = DriveKit (text)
data = HistoryVersion(json)
}
]]--
Call the deleteHistoryVersions method to delete a historical version of a file.
library.deleteHistoryVersions({fileId="xxxx", historyVersionId="xxxx"}, function(event)
print(json.prettify( event ))
end)
--Result
--[[(Listener) Table {
isError = true|false
message = text
type = deleteHistoryVersions (text)
provider = DriveKit (text)
}
]]--
HMS Drive Kit Check
MIT