Start a new topic
Answered

Swift set ACL globalRead = true for files

Hi, I am trying to upload Files to Kinvey that are globally readable.  Here is the code I use:


  

let fileStore = FileStore.getInstance()
            let file = File()
            file.publicAccessible = true
            file.acl?.globalRead.value = true
            fileStore.upload(file, data: imageData) { file, error in
                if let file = file, let fileId = file.fileId {
                    //success
                } else {
                    print("help")
                }
            }

I am using the Kinvey iOS SDK 3.3.8.


My file uploads correctly, but when I look in the data browser, the value for "_acl" is always only { creator : "creator_value_id" }.  If I manually change the "_acl" in the data browser to include "gr:true", then my file becomes globally readable like I want it to be.

Is there any way for me to set the globalRead value in code, so that the file will be globally readable when it is saved in the DB?


Thanks


Best Answer

Hello Nick,


We believe that if you tweak your code as follows, this should work as intended.


Instead of doing the code in the following block...


file.acl?.globalRead.value = true

 

...you should code it as follows.

 

let acl = Acl()
acl.globalRead.value = true
file.acl = acl

Or..

file.acl = Acl()
file.acl?.globalRead.value = true


Please one of these alternatives a try and let us know if it moves you past this problem.


Regards,


Billy Gee







Nick,

I have started looking into it and will get back to you once I have more information.

Thanks,
Pranav
Kinvey

 

Nick,

I am able to reproduce this issue and this has been escalated to engineering. Will get back to you once I have more information on this.

Thanks,
Pranav
Kinvey
MLIBZ-1728

 

Answer

Hello Nick,


We believe that if you tweak your code as follows, this should work as intended.


Instead of doing the code in the following block...


file.acl?.globalRead.value = true

 

...you should code it as follows.

 

let acl = Acl()
acl.globalRead.value = true
file.acl = acl

Or..

file.acl = Acl()
file.acl?.globalRead.value = true


Please one of these alternatives a try and let us know if it moves you past this problem.


Regards,


Billy Gee






That worked, thanks!

Hello Nick,


We're glad to hear it and thanks for confirming.


Regards,


Billy Gee

Login or Signup to post a comment