WIP - add file sizes to download links#2386
Conversation
GDSNewt
commented
Oct 23, 2025
There was a problem hiding this comment.
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}"