Remove an asset
If you need to remove an asset manually from
follow these steps:
asset = Asset.find("asset-id-from-url")(e.g.
57a9c52b40f0b608a700000a) or for a Whitehall asset
asset = WhitehallAsset.find_by(legacy_url_path: '/government/uploads/system/uploads/attachment_data/file/id/path.extension')
- Make a note of the path of the asset:
asset.file.path- this will be used to delete the file from the file system
- Mark the asset as deleted (and remove it from S3 if necessary - this will prevent restoration)
- Remove the asset from asset-manager file system (it may not be here as these are automatically removed after S3 upload)
- Use the path identified in step 5 to check for the file by removing the
sudo rm path/to/file
- Add a cache bust and check that the asset responds with a 404 not found
- Wait 20 minutes for the cache to clear, or purge it yourself
- Verify that the asset is not there
- Request removal of the asset using the Google Search Console
You might need to look at the timestamps or other information to figure out which records to delete if two assets share the same filename.
HM Courts & Tribunals Service (HMCTS) occasionally request this through Zendesk.