
On Tue, Oct 30, 2012 at 9:25 AM, han zheng <z.han0903@gmail.com> wrote:
Is there a way to directly upload a local file to the "tahoe cloud" not using the web server?
Tahoe-LAFS doesn't offer any API reachable from other processes (command-line, kernel, or remote-procedure-call) which *doesn't* route through the webapi. The diagram "network-and-reliance-toplogy.svg" 9 shows this architecture. Everything goes through the "Tahoe-LAFS gateway", and the only API that the Tahoe-LAFS gateway exports is the webapi. 9 https://tahoe-lafs.org/trac/tahoe-lafs/browser/docs/network-and-reliance-top... Han Zheng: why do you want to upload a local file to the tahoe grid not using the web server? The way to accomplish that is to write some Python code that runs in the same Python process as the Tahoe-LAFS gateway. The way that I find easiest to do such things is to look at other code that already does it and copy and modify that. So, here is the code that gets run when someone makes a PUT request to the webapi (as described in webapi.rst 2): 2 https://tahoe-lafs.org/trac/tahoe-lafs/browser/git/docs/frontends/webapi.rst... web/root.py parses the HTTP request and decides what sort of upload this is (mutable or immutable): https://tahoe-lafs.org/trac/tahoe-lafs/browser/git/src/allmydata/web/root.py?annotate=blame&rev=880af4e1fd398adb290ed7cb6c56c1d2306a0481#L40 Then it calls web/unlinked.py which constructs a FileHandle object. That object is provides the interface that the uploader expects, and it has a handle (open file descriptor) to the file on disk from which it will read the data while the data is being uploaded. https://tahoe-lafs.org/trac/tahoe-lafs/browser/git/src/allmydata/web/unlinked.py?annotate=blame&rev=3d771132a843a85578dc23a6cac55b4fae09fc64#L12 Then (after an unnecessary layer of indirection that I'm skipping), immutable/upload.py starts doing some real work: setting the encoding parameters, deciding whether to literalize this immutable file, etc: https://tahoe-lafs.org/trac/tahoe-lafs/browser/git/src/allmydata/immutable/upload.py?annotate=blame&rev=3a1c02cfdfd0d7ca09037c05b5e82dd3d402df40#L1543 So, if you write some Python code that invokes immutable/upload.py's "upload()" method, and passes an "uploadable" as the argument (note that in case shown above the "uploadable" is the FileHandle object constructed by web/unlinked.py), then you'll upload a file directly to the grid. Regards, Zooko _______________________________________________ tahoe-dev mailing list tahoe-dev@tahoe-lafs.org https://tahoe-lafs.org/cgi-bin/mailman/listinfo/tahoe-dev ----- End forwarded message ----- -- Eugen* Leitl <a href="http://leitl.org">leitl</a> http://leitl.org ______________________________________________________________ ICBM: 48.07100, 11.36820 http://www.ativel.com http://postbiota.org 8B29F6BE: 099D 78BA 2FD3 B014 B08A 7779 75B0 2443 8B29 F6BE
participants (1)
-
Zooko Wilcox-O'Hearn