Get url for files in the file system

99 views
Skip to first unread message

marcus

unread,
Aug 30, 2014, 5:46:03 AM8/30/14
to rav...@googlegroups.com
I'm trying to create a simple asset manager using RavenDB and the upcoming filesystem in v3 but I can't figure out how to get the url for the files. In this example the path is empty?

using (var client = new AsyncFilesServerClient("http://localhost:8080", "Blob"))
{
    var files = await client.BrowseAsync();
                
    return new ContentResult
    {
        Content = string.Join(", ", files.Select(x => x.Path))
    };
};


Federico Lois

unread,
Aug 30, 2014, 11:53:22 AM8/30/14
to rav...@googlegroups.com
Hi Marcus, you are using the low level api.  The ability to download, search and stream the data is simplified using the FilesStore and the FilesSession.

The url is a request to ravenfs with the filesystem and the file in the director y structure. With the high level Api you hace a FileHeader abstraction that handles that for you.

From: marcus
Sent: ‎30/‎08/‎2014 06:46 a.m.
To: rav...@googlegroups.com
Subject: [RavenDB] Get url for files in the file system

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

marcus

unread,
Aug 30, 2014, 12:37:14 PM8/30/14
to rav...@googlegroups.com
Ok, cool! But this this code does not contain any Path either?

            using(var store = new FilesStore() { Url = "http://localhost:8080", DefaultFileSystem = "Blob" }.Initialize())
            {
                using(var session = store.OpenAsyncSession())
                {
                    var files = await session.Query().ToListAsync();

Federico Lois

unread,
Aug 30, 2014, 3:44:38 PM8/30/14
to rav...@googlegroups.com
Ley me try to understand. You want to serve the file externally right? Like with a link from the website?

From: marcus
Sent: ‎30/‎08/‎2014 01:37 p.m.
To: rav...@googlegroups.com
Subject: Re: [RavenDB] Get url for files in the file system

marcus

unread,
Aug 31, 2014, 3:11:04 AM8/31/14
to rav...@googlegroups.com
I'm developing a simple asset manager so yes, I need to create a simple ul > li in HTML, with img tags where the src points to correct URL of the image. I also need to print the actual size, width and height on the img tag. So, in my controller I need to compose a view model with file/image objects that contains this information.

Oren Eini (Ayende Rahien)

unread,
Aug 31, 2014, 5:29:15 AM8/31/14
to ravendb
Path is the _directory name_.
Name is the full name.

If you are storing the images directly on the root, the path is going to be null or empty.

The URL you need is:





Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





On Sun, Aug 31, 2014 at 10:11 AM, marcus <mar...@meridium.se> wrote:
I'm developing a simple asset manager so yes, I need to create a simple ul > li in HTML, with img tags where the src points to correct URL of the image. I also need to print the actual size, width and height on the img tag. So, in my controller I need to compose a view model with file/image objects that contains this information.

Mircea Chirea

unread,
Aug 31, 2014, 7:39:32 AM8/31/14
to rav...@googlegroups.com
You've pretty much made it as confusing as .NET, where fileName is in fact the full path (or just file name if in the current directory).

Why not have just the full path? Let the use use Path.Get* to get the filename, extension, whatever.

marcus

unread,
Aug 31, 2014, 8:43:02 AM8/31/14
to rav...@googlegroups.com
Ok, so I can't get the complete url in any way then?

Another question, I need to handle different sizes of the same image, like thumbnail, small, medium or whatever. Do you have any good suggestion on how to handle this in RavenFS?

Oren Eini (Ayende Rahien)

unread,
Aug 31, 2014, 8:49:16 AM8/31/14
to ravendb
/images/img01/small.png
/images/img01/large.png

Note that it is expected that your users WON'T be connecting directly to RavenFS. 

marcus

unread,
Aug 31, 2014, 8:56:30 AM8/31/14
to rav...@googlegroups.com
Ah, that would be a pretty nice approach, and easy to understand. In your example, do you think of img01 as a generated Id or is it just the name, without extension?

Oren Eini (Ayende Rahien)

unread,
Aug 31, 2014, 8:57:57 AM8/31/14
to ravendb
It can be either one of those.

marcus

unread,
Aug 31, 2014, 10:12:25 AM8/31/14
to rav...@googlegroups.com
Ok, last question for today then :) ...

if I always want to create a thumbnail in a specific width and height, can I use any listeners or something and put the resize/crop code there or what other hooks are there?

Oren Eini (Ayende Rahien)

unread,
Aug 31, 2014, 10:47:16 AM8/31/14
to ravendb
You can use the Changes API in the file system to listen to changes, then do something then, sure.

Federico Lois

unread,
Aug 31, 2014, 2:20:37 PM8/31/14
to rav...@googlegroups.com
If we would introduce a listener like: IFileUpdatedListener would it make a difference for your use case?

The reason behind your app needing to expose the download interface is rooted in replication. If we allow to link directly to the storage, there is no way a failover server would take over if the node fails. The client would solve that for you going to another known replicated storage in case the master is down.


Tom Allard

unread,
Aug 31, 2014, 3:25:44 PM8/31/14
to rav...@googlegroups.com
We moved away from pre-storing/pre-generating images in various sizes because it isn't very flexible. The biggest problem is that if your designer need another image size you need to reprocess all of your images.


On first sight it would seem straightforward to create a virtual file provider to link to ravenfs.

-Tom

marcus

unread,
Sep 1, 2014, 3:16:29 AM9/1/14
to rav...@googlegroups.com
I haven't decided how I want it to work yet, but I think I have reason to get back to this subject in the near future.

marcus

unread,
Sep 1, 2014, 3:17:23 AM9/1/14
to rav...@googlegroups.com
Are you storing all conversions from imageresizer in RavenFS or do you just store the original?

Tom Allard

unread,
Sep 1, 2014, 4:09:45 AM9/1/14
to rav...@googlegroups.com
We just store the original (currently in the file system not (yet) in ravenfs). Imageresizer has a diskcache for the resized images wich is very performant. For instance, it removes all kinds of overhead from the IIS/ASP.NET pipeline to have lower latencies, lower CPU, etc... There is also a ton of info on that site about image resizing itself that we didn't know about when we designed our own image resizing routines. (Specific memory leaks in the Bitmap class and things like that)

-Tom
Reply all
Reply to author
Forward
0 new messages