-
Notifications
You must be signed in to change notification settings - Fork 12
/
s3_get.c
68 lines (49 loc) · 1.56 KB
/
s3_get.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
*
* Copyright(c) 2009, Vlad Korolev, <vlad[@]v-lad.org >
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://www.gnu.org/licenses/lgpl-3.0.txt
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms of the COPYING file.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*/
#include <stdio.h>
#include <stdlib.h>
#include "aws4c.h"
int main ( int argc, char * argv[] )
{
aws_init ();
aws_set_debug ( 1 );
int rc = aws_read_config ( "sample" );
if ( rc )
{
puts ( "Could not find a credential in the config file" );
puts ( "Make sure your ~/.awsAuth file is correct" );
exit ( 1 );
}
s3_set_host ( "s3.amazonaws.com");
s3_set_bucket ("aws4c.samples");
IOBuf * bf = aws_iobuf_new ();
int rv = s3_get ( bf, "aws4c.samplefile" );
printf ( "RV %d\n", rv );
printf ( "CODE [%d] \n", bf->code );
printf ( "RESULT [%s] \n", bf->result );
printf ( "LEN [%d] \n", bf->len );
printf ( "C-LEN [%d] \n", bf->contentLen );
printf ( "LASTMOD [%s] \n", bf->lastMod );
printf ( "ETAG [%s] \n", bf->eTag );
while(-1)
{
char Ln[1024];
int sz = aws_iobuf_getline ( bf, Ln, sizeof(Ln));
if ( Ln[0] == 0 ) break;
printf ( "S[%3d] %s", sz, Ln );
}
aws_iobuf_free ( bf );
return 0;
}