box / box-python-sdk

Box SDK for Python
http://opensource.box.com/box-python-sdk/
Apache License 2.0
419 stars 215 forks source link

Not able to Lock files #858

Closed Sevillesilveira closed 10 months ago

Sevillesilveira commented 10 months ago

The code is as below: lock = client.folder(folder_id='233490176640').create_lock() print(f'Created a lock with ID {lock.folder.id}')

The output: image

But I am still able to move the files in this particular folder and even delete it. Kindly let me know how to resolve this issue.

congminh1254 commented 10 months ago

Hi @Sevillesilveira

Thanks for using our Python SDK, I tried to use folder locks from my account but it's working as expected.

To further more investigate this issue, can you use the get_locks function to see if actually a lock created for the folder.

If there is a lock with move and delete locked, but you still able to move or delete folder, it's an unexpected behavior for the Box API, so you can send this question to Box Support and they will check it deeper.

Best regards, Minh

Sevillesilveira commented 10 months ago

Thank you @congminh1254 I was able to lock the folders later on but the files in these folders can still be moved. Is there a way to prevent the files in the locked folders from being edited or moved to a different location.

congminh1254 commented 10 months ago

Hi @Sevillesilveira Sorry for the confusion, but the folder locked is not affecting for the file inside folder. If you want to lock multiple files, unfortunately it's not able to do it in single request. By using this client.file(file_id).update_info method, you can create lock for single file with an expiring time. This prevents the item from being moved, renamed, or otherwise changed by anyone other than the user who created the lock. Best, Minh

Sevillesilveira commented 10 months ago

Hi @congminh1254 Could you provide me with the code to prevent files from being moved. I am unable to get the file information in JSON format in VS Code and I don't know how each parameter is named for the files. image The above image is the output I get after retrieving the file information which is only the name and id of the file.