[ckan-dev] File size

Alex Gartner alexandru.gartner+ckan at gmail.com
Sun Nov 8 23:27:15 UTC 2015


Hi,

thank you both for the replies.

Alex, I've used your way of retrieving the file size from disk and I
changed both package_show() and resource_show() to fetch this information
if the 'size' field is empty. This way the size information gets indexed in
solr and doesn't need to be read from disk each time:
https://github.com/OCHA-DAP/hdx-ckan/commit/8e2f7afd3831fb3c5e1a21a976381a2ab125c69a#diff-df5e9bd6a69646ebb213d9be4b2b31f7R295

Timothy, please let me know when the  extension is available online. It
sounds quite interesting.

On Fri, Nov 6, 2015 at 9:47 AM, Timothy Giles <timothy.giles at slu.se> wrote:

> 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
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20151109/aeeb572a/attachment-0003.html>


More information about the ckan-dev mailing list