Virtual File System

236 views
Skip to first unread message

Devian

unread,
Nov 3, 2013, 6:01:37 AM11/3/13
to js...@googlegroups.com
Can anyone point me to a jsDAV example/manual on how to create a virtual file system. Because I can't find documentation about it, except this: http://code.google.com/p/sabredav/wiki/VirtualFilesystems
But that's not in nodeJS.

Thanks in advance
Devian

Mike de Boer

unread,
Nov 10, 2013, 7:58:58 AM11/10/13
to Devian, js...@googlegroups.com
Hi Devian,

Sorry for replying late! For now only a short message: there's more information on the jsdav wiki on github.

I'll post a more elaborate message when I'm not on the road anymore after this weekend.

Cheers,

Mike.

Sent from Mailbox for iPhone


--
You received this message because you are subscribed to the Google Groups "jsdav" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdav+un...@googlegroups.com.

Devian

unread,
Dec 4, 2013, 7:16:42 PM12/4/13
to js...@googlegroups.com, Devian
Thank you Mike,
I went to the jsDAV wiki on gitHub but I found only one example (on the getting started page) on how to make a mirror of a folder structure on my own drive. But I need to make a virtual file system, so I had a look at the sabreDav wiki and tried to rewrite an existing (php) example to javascript. This resulted in the following code:
var jsDAV = require("jsDAV");
jsDAV.debugMode = true;
var File = require("jsDAV/lib/DAV/file");
var MyFile = File.extend({
    initialize: function(path) {
console.log("myFile > initialize");
        this.path = path;
    },

getName: function() {
console.log("myFile > getName");
return "Hello World";
},

"get": function() {
console.log("myFile > get");
return (new Buffer("Hello"));
},
 
getSize: function() {
console.log("myFile > getSize");
return 5;
},
getETag: function() {
console.log("myFile > getETag");
return null;
}
});
var Directory = require("jsDAV/lib/DAV/collection");
var myDirectory = Directory.extend({
    initialize: function(path) {
console.log("myDirectory > initialize");
        this.path = path;
    },

getChildren: function() {
console.log("myDirectory > getChildren");
return (new Array());
},

getChild: function(name) {
console.log("myDirectory > getChild");
return MyFile.new("Hello World");
},

childExists: function(name) {
console.log("myDirectory > childExists");
return true;
},

getName: function() {
console.log("myDirectory > getName");
return "Hello World";
}
});


var server = jsDAV.createServer({node: myDirectory.new("eenMap")}, 8000); 

OK I run this code in nodejs with no errors. Then I connect with Finder to "127.0.0.1:8000", this shows me a login window but when I select the guest option and click "connect", this window pops up and never closes 

Do you know what's the problem here or can you point me to a simple jsDAV example? Because I only find sabreDAV examples and don't know how to port these to javascript...

This is the log from nodejs:

myDirectory > initialize

[info] jsDAV server running on http://127.0.0.1:8000

[info] {1} OPTIONS /

[info] {1} { host: '127.0.0.1:8000',

[info]   accept: '*/*',

[info]   'content-length': '0',

[info]   connection: 'close',

[info]   'user-agent': 'WebDAVLib/1.3' }

[info] Receiving headers: {"host":"127.0.0.1:8000","accept":"*/*","content-length":"0","connection":"close","user-agent":"WebDAVLib/1.3"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {1} 200 { Allow: 'OPTIONS,GET,HEAD,DELETE,PROPFIND,PUT,PROPPATCH,COPY,MOVE,REPORT',

[info]   'MS-Author-Via': 'DAV',

[info]   'Accept-Ranges': 'bytes',

[info]   'X-jsDAV-Version': '0.3.2',

[info]   'Content-Length': 0,

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {1} ''

^Cmbp-van-damiaan:KHLfiles Damiaan$ node server

myDirectory > initialize

[info] jsDAV server running on http://127.0.0.1:8000

[info] {1} OPTIONS /

[info] {1} { host: '127.0.0.1:8000',

[info]   accept: '*/*',

[info]   'content-length': '0',

[info]   connection: 'keep-alive',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)' }

[info] Receiving headers: {"host":"127.0.0.1:8000","accept":"*/*","content-length":"0","connection":"keep-alive","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {1} 200 { Allow: 'OPTIONS,GET,HEAD,DELETE,PROPFIND,PUT,PROPPATCH,COPY,MOVE,REPORT',

[info]   'MS-Author-Via': 'DAV',

[info]   'Accept-Ranges': 'bytes',

[info]   'X-jsDAV-Version': '0.3.2',

[info]   'Content-Length': 0,

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {1} ''

[info] {2} OPTIONS /

[info] {2} { host: '127.0.0.1:8000',

[info]   accept: '*/*',

[info]   'content-length': '0',

[info]   connection: 'close',

[info]   'user-agent': 'WebDAVLib/1.3' }

[info] Receiving headers: {"host":"127.0.0.1:8000","accept":"*/*","content-length":"0","connection":"close","user-agent":"WebDAVLib/1.3"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {2} 200 { Allow: 'OPTIONS,GET,HEAD,DELETE,PROPFIND,PUT,PROPPATCH,COPY,MOVE,REPORT',

[info]   'MS-Author-Via': 'DAV',

[info]   'Accept-Ranges': 'bytes',

[info]   'X-jsDAV-Version': '0.3.2',

[info]   'Content-Length': 0,

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {2} ''

[info] {3} PROPFIND /

[info] {3} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {3} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

[info] {3} 207 { 'content-type': 'application/xml; charset=utf-8',

[info]   vary: 'Brief,Prefer',

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {3} '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml"><d:response><d:href>/</d:href><d:propstat><d:prop><d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">Thu, 05 Dec 2013 01:06:18 +0100</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 Ok</d:status></d:propstat><d:propstat><d:prop></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>'

[info] {4} PROPFIND /

[info] {4} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {4} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

[info] {4} 207 { 'content-type': 'application/xml; charset=utf-8',

[info]   vary: 'Brief,Prefer',

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {4} '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml"><d:response><d:href>/</d:href><d:propstat><d:prop><d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">Thu, 05 Dec 2013 01:06:18 +0100</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 Ok</d:status></d:propstat><d:propstat><d:prop></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>'

[info] {5} PROPFIND /

[info] {5} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {5} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

[info] {5} 207 { 'content-type': 'application/xml; charset=utf-8',

[info]   vary: 'Brief,Prefer',

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {5} '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml"><d:response><d:href>/</d:href><d:propstat><d:prop><d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">Thu, 05 Dec 2013 01:06:18 +0100</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 Ok</d:status></d:propstat><d:propstat><d:prop></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>'

[info] {6} PROPFIND /

[info] {6} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {6} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

[info] {6} 207 { 'content-type': 'application/xml; charset=utf-8',

[info]   vary: 'Brief,Prefer',

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {6} '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml"><d:response><d:href>/</d:href><d:propstat><d:prop><d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">Thu, 05 Dec 2013 01:06:18 +0100</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 Ok</d:status></d:propstat><d:propstat><d:prop></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>'

[info] {7} PROPFIND /

[info] {7} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {7} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

[info] {7} 207 { 'content-type': 'application/xml; charset=utf-8',

[info]   vary: 'Brief,Prefer',

[info]   DAV: '1,3,extended-mkcol,2' }

[info] {7} '<?xml version="1.0" encoding="utf-8"?><d:multistatus xmlns:d="DAV:" xmlns:a="http://ajax.org/2005/aml"><d:response><d:href>/</d:href><d:propstat><d:prop><d:getlastmodified xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">Thu, 05 Dec 2013 01:06:18 +0100</d:getlastmodified><d:resourcetype><d:collection/></d:resourcetype></d:prop><d:status>HTTP/1.1 200 Ok</d:status></d:propstat><d:propstat><d:prop></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>'

[info] {8} PROPFIND /._.

[info] {8} { host: '127.0.0.1:8000',

[info]   'content-type': 'text/xml',

[info]   depth: '0',

[info]   accept: '*/*',

[info]   'user-agent': 'WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)',

[info]   'content-length': '179',

[info]   connection: 'keep-alive' }

[info] Receiving headers: {"host":"127.0.0.1:8000","content-type":"text/xml","depth":"0","accept":"*/*","user-agent":"WebDAVFS/3.0.0 (03008000) Darwin/13.0.2 (x86_64)","content-length":"179","connection":"keep-alive"}

[info] Returning headers: {"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, DELETE, TRACE, OPTIONS, CONNECT, PATCH, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL, MERGE, BASELINE-CONTROL, MKACTIVITY, GETLIB","Access-Control-Max-Age":"86400","Access-Control-Allow-Headers":["accept","accept-charset","accept-encoding","accept-language","authorization","content-length","content-type","host","origin","proxy-connection","referer","user-agent","x-requested-with"],"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Origin":"*"}

[info] {8} <?xml version="1.0" encoding="utf-8"?>

[info] <D:propfind xmlns:D="DAV:">

[info] <D:prop>

[info] <D:getlastmodified/>

[info] <D:getcontentlength/>

[info] <D:creationdate/>

[info] <D:resourcetype/>

[info] </D:prop>

[info] </D:propfind>

[info] 

myDirectory > getChild

myFile > initialize

Reply all
Reply to author
Forward
0 new messages