Skip to main content
Table of contents


Replace an asset's file

If you need to replace the file of an existing attachment without changing the URL, follow these steps:

  1. Copy the new file from your computer to a backend server:

    scp filename.ext <hostname>:/tmp/filename.ext
  2. ssh <hostname>

  3. govuk_app_console asset-manager

  4. Find the asset:

    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.ext')`
  5. Check the asset is what you think it is.

  6. Replace the file:

    asset.file ="/tmp/filename.ext").open!
This page was last reviewed on 17 March 2020. It needs to be reviewed again on 17 June 2020 by the page owner #govuk-2ndline .
This page was set to be reviewed before 17 June 2020 by the page owner #govuk-2ndline. This might mean the content is out of date.