Revision 1c366ac9 docs/examplesdir/updownload.rst

b/docs/examplesdir/updownload.rst
1 1
Upload and Downloads
2 2
====================
3 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
Enter file context
8

  
9
.. code-block:: console
10

  
11
    $ kamaki
12
    [kamaki]: file
13
    [file]:
4
The operations of uploading files to Pithos+ as objects, and downloading
5
objects from Pithos+ as files are presented in this section.
14 6

  
15 7
Upload a file or a directory
16 8
----------------------------
......
19 11

  
20 12
.. code-block:: console
21 13

  
22
    [file]: ! ls -F
14
    $ ls -F
23 15
    file2upload.txt
24 16
    dir2upload/
25
    [file]: list
17
    $ kamaki container list
26 18
    pithos (36MB, 5 objects)
27 19
    trash  (0B, 0 objects)
28 20

  
29
.. note:: the `!` symbol is used to run host shell commands
30

  
31
Upload `file2upload.txt` to remote container `pithos`
21
Upload `file2upload.txt` to the default container (`pithos`)
32 22

  
33 23
.. code-block:: console
34 24

  
35
    [file]: upload file2upload.txt pithos
36
    Uploading /home/someuser/file2upload.txt --> pithos:file2upload.txt
25
    $ kamaki file upload file2upload.txt
26
    Uploading /home/someuser/file2upload.txt --> /pithos/file2upload.txt
37 27
    Done
38 28

  
39
Check remote container `pithos` to confirm
29
Confirm
40 30

  
41 31
.. code-block:: console
42 32

  
43
    [file]: list pithos
33
    $ kamaki file list
44 34
    2 KB file2upload.txt
45 35
    2KB  info.txt
46 36
    D    video/
47 37
    11MB video/tk1.mpg
48 38
    12MB video/tk2.mpg
49 39
    13MB video/tk3.mpg
50
    [file]:
51 40

  
52 41
Attempt to upload a whole directory, fail and retry with correct arguments
53 42

  
54 43
.. code-block:: console
55 44

  
56
    [file]: upload dir2upload pithos
45
    $ kamaki file upload dir2upload
57 46
    /home/someuser/dir2upload is a directory
58
    |  Use -R to upload directory contents
59
    [file]: upload -R dirupload pithos
60
    mkdir pithos:dir2upload
61
    Uploading /home/someuser/dir2upload/large.mov --> pithos:dir2upload/large.mov
62
    Uploading /home/someuser/dir2upload/small.mov --> pithos:dir2upload/small.mov
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
63 52
    Done
64
    [file]: list pithos
53
    $ kamaki file list
65 54
    D    dir2upload/
66 55
    1GB  dir2upload/large.mov
67 56
    1MB  dir2upload/small.mov
......
71 60
    11MB video/tk1.mpg
72 61
    12MB video/tk2.mpg
73 62
    13MB video/tk3.mpg
74
    [file]:
75 63

  
76
.. note:: Try to reupload the files (use the -f option to override) and notice
77
    how much faster is the uploading now. Pithos can determine what parts
78
    (blocks) of the file are already uploaded. Kamaki will, then, upload only
79
    the missing pars, if any.
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.
80 68

  
81 69
Download an object or a directory
82 70
---------------------------------
......
85 73

  
86 74
.. code-block:: console
87 75

  
88
    [file]: download pithos:info.txt
89
    Downloading pithos:info.txt --> /home/someuser/info.txt
90
    Donw
91
    [file]:
76
    $ kamaki file download info.txt
77
    Downloading /pithos/info.txt --> /home/someuser/info.txt
78
    Done
92 79

  
93 80
Download directory `video` as a local directory with its contents.
94
We will suppose that a power failure causes the operation to stop unexpectingly
81
We assume that a power failure causes the operation to stop unexpectingly
95 82
before it's completed.
96 83

  
97 84
.. code-block:: console
98 85

  
99
    [file]: download -R pithos:video
86
    $ kamaki file download -R /pithos/video
100 87
    mkdir video
101
    Downloading pithos:video/tk1.mpg --> /home/someuser/video/tk1.mpg
88
    Downloading /pithos/video/tk1.mpg --> /home/someuser/video/tk1.mpg
102 89
    Done
103
    Downloading pithos:video/tk2.mpg --> /home/someuser/video/tk2.mpg
90
    Downloading /pithos/video/tk2.mpg --> /home/someuser/video/tk2.mpg
104 91
    <POWER FAILURE>
105 92

  
106
After we recover the terminal and load kamaki in `file` context, we find out
107
that `tk1.mpg` had been downloaded while `tk2.mpg` download is incomplete.
93
After we recover the terminal , we find out that `tk1.mpg` had been downloaded
94
while `tk2.mpg` download is incomplete.
108 95

  
109 96
.. code-block:: console
110 97

  
111 98
    $ ls -F video
112 99
    tk1.mpg 11MB
113 100
    tk2.mpg 4MB
114
    $
115 101

  
116
Let's resume the download (use -r)
102
Resume the download (use -f)
117 103

  
118 104
.. code-block:: console
119 105

  
120
    [file]: download -R pithos:video
121
    Directory video already exists
122
    | Use -r to resume
123
    [file]: download -R -r pithos:video
124
    Resuming pithos:video/tk2.mpg --> /home/someuser/video/tk2.mpg
125
    Downloading pithos:video/tk3.mpg --> /home/someuser/video/tk3.mpg
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
126 109
    Done
127
    [file]:
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.
128 114

  
129 115
Upload all
130 116
----------
131 117

  
132 118
.. code-block:: console
133 119

  
134
    [file]: upload -R -f . pithos
120
    $ kamaki file upload -r -f . /pithos
135 121
    Done
136
    [file]:
137 122

  
138 123
.. note:: In this case, all files were already uploaded, so kamaki didn't have
139 124
    to upload anything. If a file was modified, kamaki would sync it with its
140 125
    remote counterpart.
141 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

  
142 135
Download all
143 136
------------
144 137

  
145 138
.. code-block:: console
146 139

  
147
    [file]: download -R -r pithos
140
    $ kamaki file download -r -f /pithos .
148 141
    Done
149
    [file]:
150 142

  
151 143
.. note:: Kamaki determined that all remote objects already exist as local files
152 144
    too, so there is nothing to be done. If a new remote object was created or
153 145
    an old one was modified, kamaki would have sync it with a local file.
154

  
155
Exit Context
156
------------
157

  
158
.. code-block:: console
159

  
160
    [file]: exit
161
    [kamaki]:

Also available in: Unified diff