# Delete Files

Application users can delete their own files and admin users can delete their own and public files shared with everyone. &#x20;

This function will allow users to delete their files. We don't have to do much because the IAM Policy will not allow any users to delete any other files besides their own.&#x20;

```
function deleteFile(file){
    var s3 = new AWS.S3();
    var params = { Bucket: S3DocBucket, Key: file };
    s3.deleteObject(params, function(err, data) {
        if(err){
            // failed
        }else{
            // file deleted
        }
    });
}
```

