Someone uploaded (attached) a file in a Gitlab issue comment. They did not mean to share that file publicly. I can delete the comment, but the file is still available via the original direct url. The file is at:
https://gitlab.com/<username>/<repo>/uploads/<hash>/<filename>
Is there any way to completely remove files from this uploads directory?
I raised a case with GitLab support and they were able to provide a solution for this. Using GraphQL, you can delete any uploaded files you have access to.
Navigate to GitLab's GraphQL explorer: https://gitlab.com/-/graphql-explorer
Use this query to delete your file:
mutation{
uploadDelete(input: { projectPath: "YOUR_PROJECT_PATH", secret: "YOUR_SECRET_HASH_KEY" , filename: "FILE_NAME" }) {
upload {
id
size
path
}
errors
}
}
Example:
If your uploaded file path is https://gitlab.com/s_shaik/ci256986/uploads/abefe4f256e91ffc212c40605ae91ab3/ci.yml
Then
projectPath
: "s_shaik/ci256986"
secret
: "abefe4f256e91ffc212c40605ae91ab3"
filename
: "ci.yml"
On success you will receive a response like this:
{
"data": {
"uploadDelete": {
"upload": {
"id": "gid://gitlab/Upload/<id>",
"size": <file_size>,
"path": "@hashed/some/path/to/file"
},
"errors": []
}
}
}