I am writting some routines to allow me to work with Koofr cloud storage
Asked ChatGPT to help me and we worked out this code.
The code works Perfect. Just wondering if this is the proper way to do this.
I must have gone through 100 different ways with Chat before we got this one to work
Asked ChatGPT to help me and we worked out this code.
Create Directory on Koofr:
Sub CreateKoofrDirectory(DirUrl As String) As ResumableSub
Dim joClient As JavaObject
joClient.InitializeNewInstance("okhttp3.OkHttpClient", Null)
' Build request
Dim joBuilder As JavaObject
joBuilder.InitializeNewInstance("okhttp3.Request$Builder", Null)
joBuilder.RunMethod("url", Array(DirUrl))
' Empty body
Dim joRequestBody As JavaObject
joRequestBody = joRequestBody.InitializeStatic("okhttp3.RequestBody").RunMethod("create", Array(Null, ""))
' Set MKCOL method
joBuilder.RunMethod("method", Array("MKCOL", joRequestBody))
' Add global Authorization header
Dim Auth As String = "Basic " & authBase64
joBuilder.RunMethod("addHeader", Array("Authorization", Auth))
' Build request
Dim joRequest As JavaObject = joBuilder.RunMethod("build", Null)
' Execute synchronously (run in background thread!)
Dim joCall As JavaObject = joClient.RunMethod("newCall", Array(joRequest))
Dim joResponse As JavaObject = joCall.RunMethod("execute", Null)
Dim code As Int = joResponse.RunMethod("code", Null)
joResponse.RunMethod("close", Null)
Log($"Response Code to Create Directory ${code}"$)
Return code
End Sub
The code works Perfect. Just wondering if this is the proper way to do this.
I must have gone through 100 different ways with Chat before we got this one to work