Table of contents

Remove an asset

If you need to remove an asset manually from assets.publishing.service.gov.uk, follow these steps:

  1. ssh backend-1.production
  2. govuk_app_console asset-manager
  3. 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')
  4. Make a note of the path of the asset: asset.file.path - this will be used to delete the file from the file system
  5. Mark the asset as deleted (and remove it from S3 if necessary - this will prevent restoration)
  6. Remove the asset from asset-manager file system (it may not be here as these are automatically removed after S3 upload)
    1. ssh asset-master-1.production
    2. cd /mnt/uploads/asset-manager/assets
    3. Use the path identified in step 5 to check for the file by removing the /var/apps/asset-manager/uploads/assets prefix
    4. sudo rm path/to/file
  7. Navigate to your local fabric-scripts directory
  8. fab production class:cache cdn.purge_all:'/media/.../some-asset.pdf
  9. Check that the asset responds with a 404
  10. Request removal of the asset using the Google Search Console

* Note: 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.

This page was last reviewed . It needs to be reviewed again by the page owner #govuk-2ndline.