[ckan-dev] File size

Alex (Maxious) Sadleir maxious at gmail.com
Thu Nov 5 23:17:58 UTC 2015


For uploaded files, you can find the file path on the server side and
return the file size from the file system as a template helper.

eg.
https://github.com/datagovau/ckanext-datagovau/blob/7d6cdd4549faabeda7e91486c3f26c62165d486c/ckanext/datagovau/plugin.py#L69
https://github.com/datagovau/ckanext-datagovau/blob/98112c8df279967c23f03b2b488b2d07eb8a1da8/ckanext/datagovau/templates/package/resource_read.html#L29

On Fri, Nov 6, 2015 at 9:57 AM, Alex Gartner
<alexandru.gartner+ckan at gmail.com> wrote:
> Hello,
>
> I was digging a bit into how to store and show the file size to the user (
> for uploaded resources ). As I see CKAN doesn't automatically populate this
> field although it exists in the database and it is editable via the API.
>
> At this moment it seems to me that the simplest solution would be to get the
> file size via js in the browser ( modern browsers seem to support this ) and
> send it to the server with the resource form. The downside is that the
> client ( whether we're talking about a browser or an API client) could
> potentially send the wrong size information.
>
> Is there a better way of doing this on the server side ? I checked a bit the
> code and to me it seems kinda hard to find out the size before the resource
> is created.
> Has anybody already dealt with this issue ?
>
> Thank you,
> Alex
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list