Skip to content

WIP - add file sizes to download links#2386

Closed
GDSNewt wants to merge 1 commit into
mainfrom
Add-file-size-to-map-download-link
Closed

WIP - add file sizes to download links#2386
GDSNewt wants to merge 1 commit into
mainfrom
Add-file-size-to-map-download-link

Conversation

@GDSNewt
Copy link
Copy Markdown
Contributor

@GDSNewt GDSNewt commented Oct 23, 2025

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Copy link
Copy Markdown
Contributor

@ChrisBAshton ChrisBAshton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This draft PR misunderstands the objective - we're wanting to add a file size to the PDF downloads on the user facing page (i.e. https://www.gov.uk/foreign-travel-advice/algeria), not on the publisher-facing page (https://travel-advice-publisher.publishing.service.gov.uk/admin/editions/68f0d8eaf41ad229436c6204/edit).

That means updating this bit of Frontend:

      <figcaption>
        <%= render "components/download_link", {
          text: "Download a more detailed map (PDF)",
          href: content_item.map_download_url,
        } %>
      </figcaption>

Currently, there's no info in the content item for the frontend to be able to query. What we have is this:

"document": {
  "attachment_type": "file",
  "content_type": "application/pdf",
  "id": "11c573b5-39fc-4902-bf38-f10656bb7757",
  "url": "https://assets.publishing.service.gov.uk/media/615dcb70e90e071979dfeb9c/FCDO__TA__002_-_Algeria_Travel_Advice_Ed3.pdf"
},

We'll therefore need to update the presenter to pass the file size information along with all that existing metadata, so that the content item has the data and Frontend gets what it needs.

The file size info should be retrievable from within the presenter - see this rails console query on the Travel Advice Publisher database (size: 201672):

TravelAdviceEdition.last.image.raw_response_body
=> "{\"_response_info\":{\"status\":\"ok\"},\"id\":\"http://asset-manager/assets/615dcb70d3bf7f55fd843aea\",\"name\":\"FCDO__TA__002_-_Algeria_Travel_Advice_Ed3__WEB_.jpg\",\"content_type\":\"image/jpeg\",\"size\":201672,\"file_url\":\"https://assets.integration.publishing.service.gov.uk/media/615dcb70d3bf7f55fd843aea/FCDO__TA__002_-_Algeria_Travel_Advice_Ed3__WEB_.jpg\",\"state\":\"uploaded\",\"draft\":false,\"deleted\":false}"

@GDSNewt GDSNewt closed this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants