From 526069dbb3c784e39b872709fccd13c875de5584 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 19 Mar 2024 12:18:52 +1100 Subject: [PATCH] Limit enterprise image sizes on DFC API Uploaded images can be several MB in size. While offering the big size would enable other apps to resize it and store the image size they need, we have only one app using it in practice and it's using the image directly. It's much simpler and if a default size will work for others in the future then why not just serve that. We can revise this in the future. There is a DFC discussion about publishing several sizes which I started: https://github.com/datafoodconsortium/ontology/discussions/77#discussioncomment-8228094 --- engines/dfc_provider/app/services/enterprise_builder.rb | 4 ++-- swagger/dfc.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/dfc_provider/app/services/enterprise_builder.rb b/engines/dfc_provider/app/services/enterprise_builder.rb index d1af0afad9..b2087c2601 100644 --- a/engines/dfc_provider/app/services/enterprise_builder.rb +++ b/engines/dfc_provider/app/services/enterprise_builder.rb @@ -29,8 +29,8 @@ class EnterpriseBuilder < DfcBuilder # But that would require a new endpoint for a single string. add_ofn_property(e, "ofn:contact_name", enterprise.contact_name) - add_ofn_property(e, "ofn:logo_url", enterprise.logo.url) - add_ofn_property(e, "ofn:promo_image_url", enterprise.promo_image.url) + add_ofn_property(e, "ofn:logo_url", enterprise.logo_url(:small)) + add_ofn_property(e, "ofn:promo_image_url", enterprise.promo_image_url(:large)) end end diff --git a/swagger/dfc.yaml b/swagger/dfc.yaml index ba441c7dd7..02fe096be6 100644 --- a/swagger/dfc.yaml +++ b/swagger/dfc.yaml @@ -377,8 +377,8 @@ paths: dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001 ofn:long_description: "

Hello, world!

This is a paragraph.

" ofn:contact_name: Fred Farmer - ofn:logo_url: http://www.example.com/rails/active_storage/url/logo.png - ofn:promo_image_url: http://www.example.com/rails/active_storage/url/promo.png + ofn:logo_url: http://test.host/rails/active_storage/url/logo.png + ofn:promo_image_url: http://test.host/rails/active_storage/url/promo.png dfc-b:affiliates: http://test.host/api/dfc/enterprise_groups/60000 - "@id": http://test.host/api/dfc/addresses/40000 "@type": dfc-b:Address