rejetto forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - skb

Pages: 1 2 3 4
46
HTML & templates / filelist.tpl ignored?
« on: December 22, 2014, 04:00:44 AM »
I would like to get a basic file list that also gives the modification time for each file. From the docs page http://www.rejetto.com/wiki/index.php?title=HFS:_Hidden_things

I added a basic filelist.tpl text file to my C:\hfs folder, which is where I have my hfs.exe file. Then I changed to just item-name rather than item-full-url, and also added %item-modified% . Thus, my full filelist.tpl is now:

Code: [Select]
%files%

[files]
%list%

[file]
%item-name%
%item-modified%

[folder]
%item-name%


I'm running version 2.3d(292) which I just downloaded, so I hope it is current. However, the output with ~files.lst is unchanged with this filelist.tpl added; I still get the full url for the files, with no time stamps.

Here is a listing of my HFS folder:
Quote
C:\>dir hfs
 Volume in drive C has no label.
 Volume Serial Number is C8D9-DF60

 Directory of C:\hfs

12/21/2014  10:52 PM    <DIR>          .
12/21/2014  10:52 PM    <DIR>          ..
12/21/2014  08:54 PM               404 bus-files.vfs
12/21/2014  10:20 PM                94 filelist.tpl
12/21/2014  08:24 PM         2,499,072 hfs.exe
12/21/2014  10:52 PM             3,956 hfs.ini
12/21/2014  08:22 PM    <DIR>          servedfiles
               4 File(s)      2,503,526 bytes
               3 Dir(s)  206,939,844,608 bytes free

I've tried "Debug > Temporarily Reset Options" and it made no difference.

Am I missing something obvious? Seems like this should just work

47
Thanks dj! That's exactly what I was hoping for. (Guess I missed it in the Template docs).

Cheers,
Steve

48
Interesting question, and worth testing -- so far I'd been using Chrome as that's what Phonegap Apps run as on Androids.

But, similar results from Firefox: my code can read / download files via javascript from sites that include the server response header "Access-Control-Allow-Origin: *", and it fails on sites that don't.

Both Chrome and Firefox fail silently on the un-allowed request, but with the "element inspector" open, Chrome shows an error message on the console. Firefox still just fails silently.

So, for either browser, I'm looking for a way to get HFS to let me set a response header.

(Also, to be sure I'm not missing the obvious: there's no way to generate these response headers from HTML, right? The googles I've done suggest changes to the various server config files, though obviously they're talking about much more complex servers.)

Thanks, Steve


49
I've tested my Javascript file download routine by fetching webpages as text from other sites, e.g. http://www.html5rocks.com notes that they include the "Access-Control-Allow-Origin: *" response header throughout their site, and I can download those pages as files. However, when I run the same download code against HFS on either my localhost or on another machine on my LAN, I get the warning in developer tools that ""XMLHttpRequest cannot load [...]No 'Access-Control-Allow-Origin' header is present on the requested resource."

Thus, I think being able to add this response header is what I need. Seems it might be possible to have a template area for specifying response headers, at least for simple fixed text ones like this. That way, the default HFS behavior wouldn't change, but it would be easy for those who'd like Javascript access to their HFS sites to allow it.

Thanks for your consideration,
Steve

50
Hi,

Just learning my way around HFS, and have not tried much yet, so maybe this is simple to figure out on my own. I'm working on an Android Phonegap (thus Javascript) app that will be used for data collection into some CSV files from the server. At the start of the shift the user will connect to the LAN with the HFS server, and my program on their tablet will connect to their folder on the server, and  download one or more data files with XMLHttpRequest(GET ... ). They will add data to the records from these files through out the day (which is the point of my app) and then at the end of the shift upload the files to the server with XMLHttpRequest(PUT ...)

One thing I see in online docs for XMLHttpRequest() is that the server should return the response header "Access-Control-Allow-Origin: *" to allow my apps to access the server "cross site" from javascript. Testing with a fixed file path from localhost, Chrome fails to download without this header, and warns (on the developer console): "XMLHttpRequest cannot load http://localhost/files/skb/test.txt. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. "

Is it possible to add this header to the HFS output?

Beyond that, I'd like to make it as easy as possible for my code to get a list of files and md5 values. I'm thinking I'll have a fairly standard top level  HFS template, which I would use to add a folder and user account for each Android data-gathering device, with each folder accessible by a single user for upload and download access. The app has a dialog for entering the URL (e.g. http://serveraddr/userfolder ) as well as the username and password to connect. (Though for first testing, just on my LAN, I'm not doing passwords yet)

I would like the template for these "android readable" folders to be as simple to parse as possible, perhaps just an <a></a> per file with the file name and md5 hash. The idea is that my app would first request the index.html page in its folder, and parse this to get the file names that it needs to download, and then would check each file's hash.

Conversely, at the end of the day, the app would upload the processed files (which will have altered filenames so they don't clash with the originals.) The app would compute a hash, upload a file, and then check that the server has the correct hash and delete its local copy of the data.

Any useful pointers on this sort of thing? Has anyone posted a template designed for machine readability?

Thanks,
Steve

Pages: 1 2 3 4