root / docs / examplesdir / updownload.rst @ 22ac5e97
History | View | Annotate | Download (3.9 kB)
1 |
Upload and Downloads |
---|---|
2 |
==================== |
3 |
|
4 |
The operations of uploading files to Pithos+ as objects, and downloading |
5 |
objects from Pithos+ as files are presented in this section. |
6 |
|
7 |
Upload a file or a directory |
8 |
---------------------------- |
9 |
|
10 |
First, check the files at the current directory |
11 |
|
12 |
.. code-block:: console |
13 |
|
14 |
$ ls -F |
15 |
file2upload.txt |
16 |
dir2upload/ |
17 |
$ kamaki container list |
18 |
pithos (36MB, 5 objects) |
19 |
trash (0B, 0 objects) |
20 |
|
21 |
Upload `file2upload.txt` to the default container (`pithos`) |
22 |
|
23 |
.. code-block:: console |
24 |
|
25 |
$ kamaki file upload file2upload.txt |
26 |
Uploading /home/someuser/file2upload.txt --> /pithos/file2upload.txt |
27 |
Done |
28 |
|
29 |
Confirm |
30 |
|
31 |
.. code-block:: console |
32 |
|
33 |
$ kamaki file list |
34 |
2 KB file2upload.txt |
35 |
2KB info.txt |
36 |
D video/ |
37 |
11MB video/tk1.mpg |
38 |
12MB video/tk2.mpg |
39 |
13MB video/tk3.mpg |
40 |
|
41 |
Attempt to upload a whole directory, fail and retry with correct arguments |
42 |
|
43 |
.. code-block:: console |
44 |
|
45 |
$ kamaki file upload dir2upload |
46 |
/home/someuser/dir2upload is a directory |
47 |
| Use -r to upload directory contents |
48 |
$ kamaki file upload -r dir2upload |
49 |
mkdir /pithos/dir2upload |
50 |
Uploading /home/someuser/dir2upload/large.mov --> /pithos/dir2upload/large.mov |
51 |
Uploading /home/someuser/dir2upload/small.mov --> /pithos/dir2upload/small.mov |
52 |
Done |
53 |
$ kamaki file list |
54 |
D dir2upload/ |
55 |
1GB dir2upload/large.mov |
56 |
1MB dir2upload/small.mov |
57 |
2 KB file2upload.txt |
58 |
2KB info.txt |
59 |
D video/ |
60 |
11MB video/tk1.mpg |
61 |
12MB video/tk2.mpg |
62 |
13MB video/tk3.mpg |
63 |
|
64 |
.. note:: Try to re-upload the files (use the -f option to override) and notice |
65 |
how much faster is the uploading now. Pithos+ can determine what parts |
66 |
(blocks) of the file are already uploaded so that only the missing pars |
67 |
will be uploaded. |
68 |
|
69 |
Download an object or a directory |
70 |
--------------------------------- |
71 |
|
72 |
Download object `info.txt` as a local file of the same name |
73 |
|
74 |
.. code-block:: console |
75 |
|
76 |
$ kamaki file download info.txt |
77 |
Downloading /pithos/info.txt --> /home/someuser/info.txt |
78 |
Done |
79 |
|
80 |
Download directory `video` as a local directory with its contents. |
81 |
We assume that a power failure causes the operation to stop unexpectingly |
82 |
before it's completed. |
83 |
|
84 |
.. code-block:: console |
85 |
|
86 |
$ kamaki file download -r /pithos/video |
87 |
mkdir video |
88 |
Downloading /pithos/video/tk1.mpg --> /home/someuser/video/tk1.mpg |
89 |
Done |
90 |
Downloading /pithos/video/tk2.mpg --> /home/someuser/video/tk2.mpg |
91 |
<POWER FAILURE> |
92 |
|
93 |
After we recover the terminal , we find out that `tk1.mpg` had been downloaded |
94 |
while `tk2.mpg` download is incomplete. |
95 |
|
96 |
.. code-block:: console |
97 |
|
98 |
$ ls -F video |
99 |
tk1.mpg 11MB |
100 |
tk2.mpg 4MB |
101 |
|
102 |
Resume the download (use -f) |
103 |
|
104 |
.. code-block:: console |
105 |
|
106 |
$ kamaki file download -r -f /pithos/video |
107 |
Resuming /pithos/video/tk2.mpg --> /home/someuser/video/tk2.mpg |
108 |
Downloading /pithos/video/tk3.mpg --> /home/someuser/video/tk3.mpg |
109 |
Done |
110 |
|
111 |
.. note:: The -f/--force argument is used for resuming or overwriting a file. |
112 |
The result of using the argument is always the same: the local file will be |
113 |
the same as the remote one. |
114 |
|
115 |
Upload all |
116 |
---------- |
117 |
|
118 |
.. code-block:: console |
119 |
|
120 |
$ kamaki file upload -r -f . /pithos |
121 |
Done |
122 |
|
123 |
.. note:: In this case, all files were already uploaded, so kamaki didn't have |
124 |
to upload anything. If a file was modified, kamaki would sync it with its |
125 |
remote counterpart. |
126 |
|
127 |
.. note:: The **/pithos** argument means "from container **pithos**", which is |
128 |
the default container. If a user needs to upload everything to another |
129 |
container e.g., **images**: |
130 |
|
131 |
.. code-block:: console |
132 |
|
133 |
$ kamaki file upload -r -f . /images |
134 |
|
135 |
Download all |
136 |
------------ |
137 |
|
138 |
.. code-block:: console |
139 |
|
140 |
$ kamaki file download -r -f /pithos . |
141 |
Done |
142 |
|
143 |
.. note:: Kamaki determined that all remote objects already exist as local files |
144 |
too, so there is nothing to be done. If a new remote object was created or |
145 |
an old one was modified, kamaki would have sync it with a local file. |