[ckan-dev] File size

Timothy Giles timothy.giles at slu.se
Fri Nov 6 07:47:28 UTC 2015


I have written an extension that updates the filename, size, MIME type and calculates various checksums (MD5, SHA1-512)

Ill see about popping it online in the next couple of days.

Regards Tim

-----Original Message-----
From: ckan-dev [mailto:ckan-dev-bounces at lists.okfn.org] On Behalf Of Alex (Maxious) Sadleir
Sent: den 6 november 2015 00:18
To: CKAN Development Discussions <ckan-dev at lists.okfn.org>
Subject: Re: [ckan-dev] File size

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
>
_______________________________________________
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