Change uploaded file permissions
I'm uploading a file (ssh_key) with a FileUpload element, in my Resource.
However, I would like to make sure the permissions for the uploaded file are 0600, but I'm not being able to do so with "afterStateUpdated" method, which I though was the way to go, like this:
This example fails to set the file permissions, since it seems not to be able to find it.
What would be the best approach to achieve this? "ssh_keys" disk is a local folder, inside the app directories.
4 Replies
Why do you need to change the directory permission, if it’s in local storage it’s not publicly accessible anyway.
Since its an ssh key, I wouldn't be able to use it if its not 0600
Is chmod() even a php command?
Might be possible too that your server user doesn’t have the permission to change permissions at the server level. Not sure.
Do you really intend to be useful or are just commenting by the sake of it ?
No offense, but first you question my attempt, then continue randomly questioning.
Yes, chmod is a PHP command, you can check this by yourself.
Finally, I have solved this issue by workaround, setting the file permissions before using it, which is not ideal, but works.
From what I've been able to investigate, it seems "local" storage has this kind of issues with visibility and permissions set.
I think I'm opening an issue on github.