File Information Question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

File Information Question

jovche.mitrejchevski
Hello,

I am building a rest service, and I`m serving information about files. So I want to serve the file downloadable link, file size and the last modification date.

The link is not a problem, but I cant get the information about the size and the last modification date. But I know that there is an information about them, because when I access the URL to download a file, inside the headers there are this kind of properties.

Any advice?

Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: File Information Question

Jeroen Reijn
Administrator
Hi,

can you describe how you are trying to expose this information from
within your bean?
That would help a lot in why it's not working.

Jeroen

On Thu, Jul 26, 2012 at 1:16 PM, jovche.mitrejchevski
<[hidden email]> wrote:

> Hello,
>
> I am building a rest service, and I`m serving information about files. So I
> want to serve the file downloadable link, file size and the last
> modification date.
>
> The link is not a problem, but I cant get the information about the size and
> the last modification date. But I know that there is an information about
> them, because when I access the URL to download a file, inside the headers
> there are this kind of properties.
>
> Any advice?
>
> Thank you!
>
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/File-Information-Question-tp7578883.html
> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: File Information Question

jovche.mitrejchevski
I have a class that is sort of model which is representing my bean in JSON format. Basically, I`m listing files, so i should provide something like this:
{
  "assets": [
    {
      "index": 1,
      "image": "url to the cover picture",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    },
    {
      "index": 2,
      "coverimage": "url to the cover picture 2",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location 2",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    }
  ]
}


So for the urls, I`m using something like this:

public String createFullAssetsUrl(final HippoBean asset, final HstRequestContext requestContext) {
        if (asset == null) {
            return null;
        }
        Mount mount = requestContext.getMount(MOUNT_ALIAS_SITE);
        if (mount == null) {
            log.error("Couldn't find site mount for rest service");
            return null;
        }
        HstLink link = requestContext.getHstLinkCreator().create(asset.getNode(), mount);
        return link.toUrlForm(requestContext, true);
    }

And now I`m wondering how to get the last date modified and the file size to provide them in the response as well. If I hit the download url of the file, in the headers are provided the information I need, so I`m sure that they are somewhere, but I don`t know how to get them.
Reply | Threaded
Open this post in threaded view
|

Re: File Information Question

Wouter Danes-2
Checked the inheritence of the default example assets and they point to a hippo:resource.
That's your file.

[hippo:resource] > nt:base
  - jcr:mimeType (string) mandatory
  - hippo:text (binary)
  - jcr:encoding (string)
  - jcr:data (binary) primary mandatory
  - jcr:lastModified (date) mandatory ignore

So the hippo:resource node should hold the information you need.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of jovche.mitrejchevski
Sent: maandag 30 juli 2012 13:23
To: [hidden email]
Subject: Re: [Hippo-cms7-user] File Information Question

I have a class that is sort of model which is representing my bean in JSON format. Basically, I`m listing files, so i should provide something like
this:
{
  "assets": [
    {
      "index": 1,
      "image": "url to the cover picture",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    },
    {
      "index": 2,
      "coverimage": "url to the cover picture 2",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location 2",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    }
  ]
}


So for the urls, I`m using something like this:

public String createFullAssetsUrl(final HippoBean asset, final HstRequestContext requestContext) {
        if (asset == null) {
            return null;
        }
        Mount mount = requestContext.getMount(MOUNT_ALIAS_SITE);
        if (mount == null) {
            log.error("Couldn't find site mount for rest service");
            return null;
        }
        HstLink link =
requestContext.getHstLinkCreator().create(asset.getNode(), mount);
        return link.toUrlForm(requestContext, true);
    }

And now I`m wondering how to get the last date modified and the file size to provide them in the response as well. If I hit the download url of the file, in the headers are provided the information I need, so I`m sure that they are somewhere, but I don`t know how to get them.



--
View this message in context: http://hippo.2275632.n2.nabble.com/File-Information-Question-tp7578883p7578908.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: File Information Question

Wouter Danes-2
public String createFullAssetsUrl(final HippoBean asset, final HstRequestContext requestContext) {

That final HippoBean asset should probably be final HippoAssetBean asset.
Then you can do asset.geResource().getLastModified()

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Wouter Danes
Sent: maandag 30 juli 2012 14:03
To: Hippo CMS 7 development public mailinglist
Subject: Re: [Hippo-cms7-user] File Information Question

Checked the inheritence of the default example assets and they point to a hippo:resource.
That's your file.

[hippo:resource] > nt:base
  - jcr:mimeType (string) mandatory
  - hippo:text (binary)
  - jcr:encoding (string)
  - jcr:data (binary) primary mandatory
  - jcr:lastModified (date) mandatory ignore

So the hippo:resource node should hold the information you need.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of jovche.mitrejchevski
Sent: maandag 30 juli 2012 13:23
To: [hidden email]
Subject: Re: [Hippo-cms7-user] File Information Question

I have a class that is sort of model which is representing my bean in JSON format. Basically, I`m listing files, so i should provide something like
this:
{
  "assets": [
    {
      "index": 1,
      "image": "url to the cover picture",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    },
    {
      "index": 2,
      "coverimage": "url to the cover picture 2",
      "title": "Title",
      "description": "Description",
      "downloadurl": "url to the resource location 2",
      "last-modified-date": "20-06-2012 14:02:34",
      "size": "123456"
    }
  ]
}


So for the urls, I`m using something like this:

public String createFullAssetsUrl(final HippoBean asset, final HstRequestContext requestContext) {
        if (asset == null) {
            return null;
        }
        Mount mount = requestContext.getMount(MOUNT_ALIAS_SITE);
        if (mount == null) {
            log.error("Couldn't find site mount for rest service");
            return null;
        }
        HstLink link =
requestContext.getHstLinkCreator().create(asset.getNode(), mount);
        return link.toUrlForm(requestContext, true);
    }

And now I`m wondering how to get the last date modified and the file size to provide them in the response as well. If I hit the download url of the file, in the headers are provided the information I need, so I`m sure that they are somewhere, but I don`t know how to get them.



--
View this message in context: http://hippo.2275632.n2.nabble.com/File-Information-Question-tp7578883p7578908.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: File Information Question

jovche.mitrejchevski
Thank you very much.
This is working well:

        public String createFullAssetsUrl(final HippoBean asset,
                        final HstRequestContext requestContext, String cannonicalPath) {
                .....
                .....
                Calendar date = bean.getFile().getAsset().getLastModified();
                mSize = bean.getFile().getAsset().getLength();
              //getFile() method is returning HippoAssetBean object.
        }

Cheers, and thanks again!