Start a new topic
Answered

Can't delete a file from code

My function (Swift):   

KCSFileStore.deleteFile(fileId, completionBlock:
            {
                (count, errorOrNil) -> Void in
                
                slotOneBusy = false
                numOfBusySlots -= 1
                
                if errorOrNil == nil
                {
                    idsOfDeletedFiles.append(fileId)
                    print("\nFile successfully deleted! (One)\n")
                }
                else
                {
                    print("\nError deleting file:")
                    print("\(errorOrNil!)\n")
                }
            }
        )

  

Response Log:


Error Domain=KCSResourceErrorDomain Code=401 "Error Deleting file, id='577c08aa-c3a5-4d85-80c0-12a4a5b79419'" UserInfo={NSUnderlyingError=0x15d08a80 {Error Domain=KCSServerErrorDomain Code=401 "The credentials used to authenticate this request are not authorized to run this operation. Please retry your request with appropriate credentials" UserInfo={Kinvey.kinveyErrorCode=InsufficientCredentials, NSLocalizedFailureReason=, NSLocalizedDescription=The credentials used to authenticate this request are not authorized to run this operation. Please retry your request with appropriate credentials, KinveyKit.HTTPMethod=DELETE, NSErrorFailingURLKey=https://baas.kinvey.com/blob/kid_bkctkcwMmW/577c08aa-c3a5-4d85-80c0-12a4a5b79419, Kinvey.RequestId=5466d9dbc49b4485ac17687faa082017}}, NSLocalizedDescription=Error Deleting file, id='577c08aa-c3a5-4d85-80c0-12a4a5b79419'}


Thanks in advance!


Best Answer

Hi Pranav, sorry the delay. I've already solved the problem: if you set file as globally writable when you save it, then anyone can delete it.


Thank you,

Nissi


Nissi,

Are you trying to delete the file using the same account as the owner of the file (user who uploaded the file)?

Thanks,
Pranav
Kinvey Support

 

Answer

Hi Pranav, sorry the delay. I've already solved the problem: if you set file as globally writable when you save it, then anyone can delete it.


Thank you,

Nissi

Login or Signup to post a comment