forked from aws/aws-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazonS3.java
More file actions
3652 lines (3546 loc) · 160 KB
/
AmazonS3.java
File metadata and controls
3652 lines (3546 loc) · 160 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.s3;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
import java.util.List;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.HttpMethod;
import com.amazonaws.services.s3.internal.Constants;
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.AccessControlList;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.BucketCrossOriginConfiguration;
import com.amazonaws.services.s3.model.BucketLifecycleConfiguration;
import com.amazonaws.services.s3.model.BucketLoggingConfiguration;
import com.amazonaws.services.s3.model.BucketNotificationConfiguration;
import com.amazonaws.services.s3.model.BucketPolicy;
import com.amazonaws.services.s3.model.BucketTaggingConfiguration;
import com.amazonaws.services.s3.model.BucketVersioningConfiguration;
import com.amazonaws.services.s3.model.BucketWebsiteConfiguration;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.CompleteMultipartUploadResult;
import com.amazonaws.services.s3.model.CopyObjectRequest;
import com.amazonaws.services.s3.model.CopyObjectResult;
import com.amazonaws.services.s3.model.CopyPartRequest;
import com.amazonaws.services.s3.model.CopyPartResult;
import com.amazonaws.services.s3.model.CreateBucketRequest;
import com.amazonaws.services.s3.model.DeleteBucketPolicyRequest;
import com.amazonaws.services.s3.model.DeleteBucketRequest;
import com.amazonaws.services.s3.model.DeleteBucketWebsiteConfigurationRequest;
import com.amazonaws.services.s3.model.DeleteObjectRequest;
import com.amazonaws.services.s3.model.DeleteObjectsRequest;
import com.amazonaws.services.s3.model.DeleteObjectsResult;
import com.amazonaws.services.s3.model.DeleteVersionRequest;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import com.amazonaws.services.s3.model.GetBucketAclRequest;
import com.amazonaws.services.s3.model.GetBucketLocationRequest;
import com.amazonaws.services.s3.model.GetBucketPolicyRequest;
import com.amazonaws.services.s3.model.GetBucketWebsiteConfigurationRequest;
import com.amazonaws.services.s3.model.GetObjectMetadataRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.GroupGrantee;
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadResult;
import com.amazonaws.services.s3.model.ListBucketsRequest;
import com.amazonaws.services.s3.model.ListMultipartUploadsRequest;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ListPartsRequest;
import com.amazonaws.services.s3.model.ListVersionsRequest;
import com.amazonaws.services.s3.model.MultiObjectDeleteException;
import com.amazonaws.services.s3.model.MultipartUploadListing;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.Owner;
import com.amazonaws.services.s3.model.PartListing;
import com.amazonaws.services.s3.model.Permission;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult;
import com.amazonaws.services.s3.model.Region;
import com.amazonaws.services.s3.model.RestoreObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.SetBucketAclRequest;
import com.amazonaws.services.s3.model.SetBucketLoggingConfigurationRequest;
import com.amazonaws.services.s3.model.SetBucketPolicyRequest;
import com.amazonaws.services.s3.model.SetBucketVersioningConfigurationRequest;
import com.amazonaws.services.s3.model.SetBucketWebsiteConfigurationRequest;
import com.amazonaws.services.s3.model.StorageClass;
import com.amazonaws.services.s3.model.UploadPartRequest;
import com.amazonaws.services.s3.model.UploadPartResult;
import com.amazonaws.services.s3.model.VersionListing;
/**
* <p>
* Provides an interface for accessing the Amazon S3 web service.
* </p>
* <p>
* Amazon S3 provides storage for the Internet,
* and is designed to make web-scale computing easier for developers.
* </p>
* <p>
* The Amazon S3 Java SDK provides a simple interface that can be
* used to store and retrieve any amount of data, at any time,
* from anywhere on the web. It gives any developer access to the same
* highly scalable, reliable, secure, fast, inexpensive infrastructure
* that Amazon uses to run its own global network of web sites.
* The service aims to maximize benefits of scale and to pass those
* benefits on to developers.
* </p>
* <p>
* For more information about Amazon S3, please see
* <a href="http://aws.amazon.com/s3">
* http://aws.amazon.com/s3</a>
* </p>
*/
public interface AmazonS3 {
/**
* <p>
* Overrides the default endpoint for this client.
* Use this method to send requests to the specified AWS region.
* </p>
* <p>
* Pass the endpoint (e.g. "s3.amazonaws.com") or a full
* URL, including the protocol (e.g. "https://s3.amazonaws.com"). If the
* protocol is not specified, the protocol from this client's
* {@link com.amazonaws.ClientConfiguration} is used.
* </p>
* @param endpoint
* The endpoint (e.g. "s3.amazonaws.com") or the full URL,
* including the protocol (e.g. "https://s3.amazonaws.com"), of
* the region-specific AWS endpoint this client will communicate
* with.
*
* @throws IllegalArgumentException
* If the specified endpoint is not a valid URL endpoint.
*/
public void setEndpoint(String endpoint);
/**
* An alternative to {@link AmazonS3#setEndpoint(String)}, sets the
* regional endpoint for this client's service calls. Callers can use this
* method to control which AWS region they want to work with.
* <p>
* <b>This method is not threadsafe. A region should be configured when the
* client is created and before any service requests are made. Changing it
* afterwards creates inevitable race conditions for any service requests in
* transit or retrying.</b>
* <p>
* By default, all service endpoints in all regions use the https protocol.
* To use http instead, specify it in the {@link ClientConfiguration}
* supplied at construction.
*
* @param region
* The region this client will communicate with. See
* {@link com.amazonaws.regions.Region#getRegion(com.amazonaws.regions.Regions)} for
* accessing a given region.
* @throws java.lang.IllegalArgumentException
* If the given region is null, or if this service isn't
* available in the given region. See
* {@link com.amazonaws.regions.Region#isServiceSupported(String)}
* @see com.amazonaws.regions.Region#getRegion(com.amazonaws.regions.Regions)
* @see com.amazonaws.regions.Region#createClient(Class, com.amazonaws.auth.AWSCredentialsProvider, ClientConfiguration)
*/
public void setRegion(com.amazonaws.regions.Region region) throws IllegalArgumentException;
/**
* <p>
* Override the default S3 client options for this client.
* </p>
* @param clientOptions
* The S3 client options to use.
*/
public void setS3ClientOptions(S3ClientOptions clientOptions);
/**
* <p>
* Changes the Amazon S3 storage class for a specified object. Amazon S3
* offers multiple storage classes for developers' different needs.
* </p>
* <p>
* Note that changing the storage class of an object in a bucket
* that has enabled versioning creates a new version of the object
* with the new storage class. The existing version of the object persists
* in the current storage class.
* </p>
*
* @param bucketName
* The name of the bucket containing the object.
* @param key
* The key of the object within the specified bucket.
* @param newStorageClass
* The new storage class for the specified object.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*/
public void changeObjectStorageClass(String bucketName, String key, StorageClass newStorageClass)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Changes the Amazon S3 redirect location for a specific object.
* </p>
* @param bucketName
* The name of the bucket containing the object.
* @param key
* The key of the object within the specified bucket.
* @param newRedirectLocation
* The new redirect location for the specified object.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*/
public void setObjectRedirectLocation(String bucketName, String key, String newRedirectLocation)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the objects in the specified
* buckets.
* List results are <i>always</i> returned in lexicographic (alphabetical) order.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of keys, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link ObjectListing#isTruncated()} method to see if the returned
* listing is complete or if additional calls are needed to get
* more results. Alternatively, use the
* {@link AmazonS3Client#listNextBatchOfObjects(ObjectListing)} method as
* an easy way to get the next page of object listings.
* </p>
* <p>
* The total number of keys in a bucket doesn't substantially
* affect list performance.
* </p>
*
* @param bucketName
* The name of the Amazon S3 bucket to list.
*
* @return A listing of the objects in the specified bucket, along with any
* other associated information, such as common prefixes (if a
* delimiter was specified), the original request parameters, etc.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listObjects(String, String)
* @see AmazonS3Client#listObjects(ListObjectsRequest)
*/
public ObjectListing listObjects(String bucketName) throws AmazonClientException,
AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the objects in the specified
* bucket. Depending on request parameters, additional information is returned,
* such as common prefixes if a delimiter was specified. List
* results are <i>always</i> returned in lexicographic (alphabetical) order.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of keys, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link ObjectListing#isTruncated()} method to see if the returned
* listing is complete or if additional calls are needed to get
* more results. Alternatively, use the
* {@link AmazonS3Client#listNextBatchOfObjects(ObjectListing)} method as
* an easy way to get the next page of object listings.
* </p>
* <p>
* For example, consider a bucket that contains the following keys:
* <ul>
* <li>"foo/bar/baz"</li>
* <li>"foo/bar/bash"</li>
* <li>"foo/bar/bang"</li>
* <li>"foo/boo"</li>
* </ul>
* If calling <code>listObjects</code> with
* a <code>prefix</code> value of "foo/" and a <code>delimiter</code> value of "/"
* on this bucket, an <code>ObjectListing</code> is returned that contains one key
* ("foo/boo") and one entry in the common prefixes list ("foo/bar/").
* To see deeper into the virtual hierarchy, make another
* call to <code>listObjects</code> setting the prefix parameter to any interesting
* common prefix to list the individual keys under that prefix.
* </p>
* <p>
* The total number of keys in a bucket doesn't substantially
* affect list performance.
* </p>
*
* @param bucketName
* The name of the Amazon S3 bucket to list.
* @param prefix
* An optional parameter restricting the response to keys
* beginning with the specified prefix. Use prefixes to
* separate a bucket into different sets of keys,
* similar to how a file system organizes files
* into directories.
*
* @return A listing of the objects in the specified bucket, along with any
* other associated information, such as common prefixes (if a
* delimiter was specified), the original request parameters, etc.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listObjects(String)
* @see AmazonS3Client#listObjects(ListObjectsRequest)
*/
public ObjectListing listObjects(String bucketName, String prefix)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the objects in the specified
* bucket. Depending on the request parameters, additional information is returned,
* such as common prefixes if a delimiter was specified. List
* results are <i>always</i> returned in lexicographic (alphabetical) order.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of keys, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link ObjectListing#isTruncated()} method to see if the returned
* listing is complete or if additional calls are needed to get
* more results. Alternatively, use the
* {@link AmazonS3Client#listNextBatchOfObjects(ObjectListing)} method as
* an easy way to get the next page of object listings.
* </p>
* <p>
* Calling {@link ListObjectsRequest#setDelimiter(String)}
* sets the delimiter, allowing groups of keys that share the
* delimiter-terminated prefix to be included
* in the returned listing. This allows applications to organize and browse
* their keys hierarchically, similar to how a file system organizes files
* into directories. These common prefixes can be retrieved
* through the {@link ObjectListing#getCommonPrefixes()} method.
* </p>
* <p>
* For example, consider a bucket that contains the following keys:
* <ul>
* <li>"foo/bar/baz"</li>
* <li>"foo/bar/bash"</li>
* <li>"foo/bar/bang"</li>
* <li>"foo/boo"</li>
* </ul>
* If calling <code>listObjects</code> with
* a prefix value of "foo/" and a delimiter value of "/"
* on this bucket, an <code>ObjectListing</code> is returned that contains one key
* ("foo/boo") and one entry in the common prefixes list ("foo/bar/").
* To see deeper into the virtual hierarchy, make another
* call to <code>listObjects</code> setting the prefix parameter to any interesting
* common prefix to list the individual keys under that prefix.
* </p>
* <p>
* The total number of keys in a bucket doesn't substantially
* affect list performance.
* </p>
*
* @param listObjectsRequest
* The request object containing all options for listing the
* objects in a specified bucket.
*
* @return A listing of the objects in the specified bucket, along with any
* other associated information, such as common prefixes (if a
* delimiter was specified), the original request parameters, etc.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listObjects(String)
* @see AmazonS3Client#listObjects(String, String)
*/
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Provides an easy way to continue a truncated object listing and retrieve
* the next page of results.
* </p>
* <p>
* To continue the object listing and retrieve the next page of results,
* call the initial {@link ObjectListing} from one of the
* <code>listObjects</code> methods.
* If truncated
* (indicated when {@link ObjectListing#isTruncated()} returns <code>true</code>),
* pass the <code>ObjectListing</code> back into this method
* in order to retrieve the
* next page of results. Continue using this method to
* retrieve more results until the returned <code>ObjectListing</code> indicates that
* it is not truncated.
* </p>
* @param previousObjectListing
* The previous truncated <code>ObjectListing</code>.
* If a
* non-truncated <code>ObjectListing</code> is passed in, an empty
* <code>ObjectListing</code> is returned without ever contacting
* Amazon S3.
*
* @return The next set of <code>ObjectListing</code> results, beginning immediately
* after the last result in the specified previous <code>ObjectListing</code>.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listObjects(String)
* @see AmazonS3Client#listObjects(String, String)
* @see AmazonS3Client#listObjects(ListObjectsRequest)
*/
public ObjectListing listNextBatchOfObjects(ObjectListing previousObjectListing)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the versions in the specified
* bucket.
* </p>
* <p>
* The returned version summaries are ordered first by key and then by
* version. Keys are sorted lexicographically (alphabetically)
* while versions are sorted from most recent to least recent.
* Both versions with data and delete markers are included in the results.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of versions, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link VersionListing#isTruncated()} method to determine if the
* returned listing is complete or if additional calls are needed to get
* more results. Callers are
* encouraged to use
* {@link AmazonS3#listNextBatchOfVersions(VersionListing)} as an easy way
* to get the next page of results.
* </p>
* <p>
* For more information about enabling versioning for a bucket, see
* {@link #setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}.
* </p>
*
* @param bucketName
* The name of the Amazon S3 bucket whose versions are to be
* listed.
* @param prefix
* An optional parameter restricting the response to keys
* beginning with the specified prefix. Use prefixes to
* separate a bucket into different sets of keys,
* similar to how a file system organizes files
* into directories.
*
* @return A listing of the versions in the specified bucket, along with any
* other associated information and original request parameters.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listVersions(ListVersionsRequest)
* @see AmazonS3Client#listVersions(String, String, String, String, String, Integer)
*/
public VersionListing listVersions(String bucketName, String prefix)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Provides an easy way to continue a truncated {@link VersionListing} and retrieve
* the next page of results.
* </p>
* <p>
* Obtain the initial
* <code>VersionListing</code> from one of the <code>listVersions</code> methods. If the result
* is truncated (indicated when {@link ObjectListing#isTruncated()} returns <code>true</code>),
* pass the <code>VersionListing</code> back into this method in order to retrieve the
* next page of results. From there, continue using this method to
* retrieve more results until the returned <code>VersionListing</code> indicates that
* it is not truncated.
* </p>
* <p>
* For more information about enabling versioning for a bucket, see
* {@link #setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}.
* </p>
*
* @param previousVersionListing
* The previous truncated <code>VersionListing</code>.
* If a
* non-truncated <code>VersionListing</code> is passed in, an empty
* <code>VersionListing</code> is returned without ever contacting
* Amazon S3.
*
* @return The next set of <code>VersionListing</code> results, beginning immediately
* after the last result in the specified previous <code>VersionListing</code>.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listVersions(String, String)
* @see AmazonS3Client#listVersions(ListVersionsRequest)
* @see AmazonS3Client#listVersions(String, String, String, String, String, Integer)
*/
public VersionListing listNextBatchOfVersions(VersionListing previousVersionListing)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the versions in the specified
* bucket.
* </p>
* <p>
* The returned version summaries are ordered first by key and then by
* version. Keys are sorted lexicographically (alphabetically)
* and versions are sorted from most recent to least recent.
* Versions
* with data and delete markers are included in the results.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of versions, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link VersionListing#isTruncated()} method to determine if the
* returned listing is complete or if additional calls are needed
* to get more results.
* Callers are
* encouraged to use
* {@link AmazonS3#listNextBatchOfVersions(VersionListing)} as an easy way
* to get the next page of results.
* </p>
* <p>
* The <code>keyMarker</code> and <code>versionIdMarker</code> parameters allow
* callers to specify where to start the version listing.
* </p>
* <p>
* The <code>delimiter</code> parameter allows groups of keys that share a
* delimiter-terminated prefix to be included
* in the returned listing. This allows applications to organize and browse
* their keys hierarchically, much like how a file system organizes
* files into directories. These common prefixes can be retrieved
* by calling the {@link VersionListing#getCommonPrefixes()} method.
* </p>
* <p>
* For example, consider a bucket that contains the following keys:
* <ul>
* <li>"foo/bar/baz"</li>
* <li>"foo/bar/bash"</li>
* <li>"foo/bar/bang"</li>
* <li>"foo/boo"</li>
* </ul>
* If calling <code>listVersions</code> with
* a <code>prefix</code> value of "foo/" and a <code>delimiter</code> value of "/"
* on this bucket, a <code>VersionListing</code> is returned that contains:
* <ul>
* <li>all the versions for one key ("foo/boo")</li>
* <li>one entry in the common prefixes list ("foo/bar/")</li>
* </ul>
* </p>
* <p>
* To see deeper into the virtual hierarchy, make
* another call to <code>listVersions</code> setting the prefix parameter to any
* interesting common prefix to list the individual versions under that
* prefix.
* </p>
* <p>
* For more information about enabling versioning for a bucket, see
* {@link #setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}.
* </p>
*
* @param bucketName
* The name of the Amazon S3 bucket whose versions are to be
* listed.
* @param prefix
* An optional parameter restricting the response to keys that
* begin with the specified prefix. Use prefixes to
* separate a bucket into different sets of keys,
* similar to how a file system organizes files
* into directories.
* @param keyMarker
* Optional parameter indicating where in the sorted list of all
* versions in the specified bucket to begin returning results.
* Results are always ordered first lexicographically (i.e.
* alphabetically) and then from most recent version to least
* recent version. If a keyMarker is used without a
* versionIdMarker, results begin immediately after that key's
* last version. When a keyMarker is used with a versionIdMarker,
* results begin immediately after the version with the specified
* key and version ID.
* <p>
* This enables pagination; to get the next page of results use
* the next key marker and next version ID marker (from
* {@link VersionListing#getNextKeyMarker()} and
* {@link VersionListing#getNextVersionIdMarker()}) as the
* markers for the next request to list versions, or use the
* convenience method
* {@link AmazonS3#listNextBatchOfVersions(VersionListing)}
* @param versionIdMarker
* Optional parameter indicating where in the sorted list of all
* versions in the specified bucket to begin returning results.
* Results are always ordered first lexicographically (i.e.
* alphabetically) and then from most recent version to least
* recent version. A keyMarker must be specified when specifying
* a versionIdMarker. Results begin immediately after the version
* with the specified key and version ID.
* <p>
* This enables pagination; to get the next page of results use
* the next key marker and next version ID marker (from
* {@link VersionListing#getNextKeyMarker()} and
* {@link VersionListing#getNextVersionIdMarker()}) as the
* markers for the next request to list versions, or use the
* convenience method
* {@link AmazonS3#listNextBatchOfVersions(VersionListing)}
* @param delimiter
* Optional parameter that causes keys that contain the same
* string between the prefix and the first occurrence of the
* delimiter to be rolled up into a single result element in the
* {@link VersionListing#getCommonPrefixes()} list. These
* rolled-up keys are not returned elsewhere in the response. The
* most commonly used delimiter is "/", which simulates a
* hierarchical organization similar to a file system directory
* structure.
* @param maxResults
* Optional parameter indicating the maximum number of results to
* include in the response. Amazon S3 might return fewer than
* this, but will not return more. Even if maxKeys is not
* specified, Amazon S3 will limit the number of results in the
* response.
*
* @return A listing of the versions in the specified bucket, along with any
* other associated information such as common prefixes (if a
* delimiter was specified), the original request parameters, etc.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listVersions(String, String)
* @see AmazonS3Client#listVersions(ListVersionsRequest)
* @see AmazonS3Client#listNextBatchOfVersions(VersionListing)
*/
public VersionListing listVersions(String bucketName, String prefix,
String keyMarker, String versionIdMarker, String delimiter, Integer maxResults)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of summary information about the versions in the specified
* bucket.
* </p>
* <p>
* The returned version summaries are ordered first by key and then by
* version. Keys are sorted lexicographically (alphabetically)
* and versions are sorted from most recent to least recent.
* Versions
* with data and delete markers are included in the results.
* </p>
* <p>
* Because buckets can contain a virtually unlimited number of versions, the
* complete results of a list query can be extremely large. To manage large
* result sets, Amazon S3 uses pagination to split them into multiple
* responses. Always check the
* {@link VersionListing#isTruncated()} method to determine if the
* returned listing is complete or if additional calls are needed
* to get more results.
* Callers are
* encouraged to use
* {@link AmazonS3#listNextBatchOfVersions(VersionListing)} as an easy way
* to get the next page of results.
* </p>
* <p>
* The <code>keyMarker</code> and <code>versionIdMarker</code> parameters allow
* callers to specify where to start the version listing.
* </p>
* <p>
* The <code>delimiter</code> parameter allows groups of keys that share a
* delimiter-terminated prefix to be included
* in the returned listing. This allows applications to organize and browse
* their keys hierarchically, much like how a file system organizes
* files into directories. These common prefixes can be retrieved
* by calling the {@link VersionListing#getCommonPrefixes()} method.
* </p>
* <p>
* For example, consider a bucket that contains the following keys:
* <ul>
* <li>"foo/bar/baz"</li>
* <li>"foo/bar/bash"</li>
* <li>"foo/bar/bang"</li>
* <li>"foo/boo"</li>
* </ul>
* If calling <code>listVersions</code> with
* a <code>prefix</code> value of "foo/" and a <code>delimiter</code> value of "/"
* on this bucket, a <code>VersionListing</code> is returned that contains:
* <ul>
* <li>all the versions for one key ("foo/boo")</li>
* <li>one entry in the common prefixes list ("foo/bar/")</li>
* </ul>
* </p>
* <p>
* To see deeper into the virtual hierarchy, make
* another call to <code>listVersions</code> setting the prefix parameter to any
* interesting common prefix to list the individual versions under that
* prefix.
* </p>
* <p>
* For more information about enabling versioning for a bucket, see
* {@link #setBucketVersioningConfiguration(SetBucketVersioningConfigurationRequest)}.
* </p>
*
* @param listVersionsRequest
* The request object containing all options for listing the
* versions in a specified bucket.
*
* @return A listing of the versions in the specified bucket, along with any
* other associated information such as common prefixes (if a
* delimiter was specified), the original request parameters, etc.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3Client#listVersions(String, String)
* @see AmazonS3Client#listVersions(String, String, String, String, String, Integer)
* @see AmazonS3Client#listNextBatchOfVersions(VersionListing)
*/
public VersionListing listVersions(ListVersionsRequest listVersionsRequest)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Gets the current owner of the AWS account
* that the authenticated sender of the request is using.
* </p>
* <p>
* The caller <i>must</i> authenticate with a valid AWS Access Key ID that is registered
* with Amazon S3.
* </p>
*
* @return The account of the authenticated sender
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*/
public Owner getS3AccountOwner() throws AmazonClientException,
AmazonServiceException;
/**
* Checks if the specified bucket exists. Amazon S3 buckets are named in a
* global namespace; use this method to determine if a specified
* bucket name already exists, and therefore can't be used to create a new
* bucket.
*
* @param bucketName
* The name of the bucket to check.
*
* @return The value <code>true</code> if the specified bucket exists in
* Amazon S3; the value
* <code>false</code> if there is no bucket in Amazon S3 with that name.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3#createBucket(CreateBucketRequest)
*/
public boolean doesBucketExist(String bucketName)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Returns a list of all Amazon S3 buckets that the
* authenticated sender of the request owns.
* </p>
* <p>
* Users must authenticate with a valid AWS Access Key ID that is registered
* with Amazon S3. Anonymous requests cannot list buckets, and users cannot
* list buckets that they did not create.
* </p>
*
* @return A list of all of the Amazon S3 buckets owned by the authenticated
* sender of the request.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3#listBuckets(ListBucketsRequest)
*/
public List<Bucket> listBuckets() throws AmazonClientException,
AmazonServiceException;
/**
* <p>
* Returns a list of all Amazon S3 buckets that the
* authenticated sender of the request owns.
* </p>
* <p>
* Users must authenticate with a valid AWS Access Key ID that is registered
* with Amazon S3. Anonymous requests cannot list buckets, and users cannot
* list buckets that they did not create.
* </p>
*
* @param request
* The request containing all of the options related to the listing
* of buckets.
*
* @return A list of all of the Amazon S3 buckets owned by the authenticated
* sender of the request.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see AmazonS3#listBuckets()
*/
public List<Bucket> listBuckets(ListBucketsRequest listBucketsRequest)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Gets the geographical region where Amazon S3 stores the specified
* bucket.
* </p>
* <p>
* To view the location constraint of a bucket, the user must be the bucket
* owner.
* </p>
* <p>
* Use {@link Region#fromValue(String)} to get the <code>Region</code>
* enumeration value, but be prepared to
* handle an <code>IllegalArgumentException</code>
* if the value passed is not a known <code>Region</code> value.
* </p>
* <p>
* Note that <code>Region</code> enumeration values are not returned
* directly from this method.
* </p>
*
* @param bucketName
* The name of the Amazon S3 bucket to look up. This must be a
* bucket the user owns.
*
* @return The location of the specified Amazon S3 bucket.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see Region
*/
public String getBucketLocation(String bucketName) throws AmazonClientException,
AmazonServiceException;
/**
* <p>
* Gets the geographical region where Amazon S3 stores the specified
* bucket.
* </p>
* <p>
* To view the location constraint of a bucket, the user must be the bucket
* owner.
* </p>
* <p>
* Use {@link Region#fromValue(String)} to get the <code>Region</code>
* enumeration value, but be prepared to
* handle an <code>IllegalArgumentException</code>
* if the value passed is not a known <code>Region</code> value.
* </p>
* <p>
* Note that <code>Region</code> enumeration values are not returned
* directly from this method.
* </p>
*
* @param getBucketLocationRequest
* The request object containing the name of the Amazon S3
* bucket to look up. This must be a bucket the user owns.
*
* @return The location of the specified Amazon S3 bucket.
*
* @throws AmazonClientException
* If any errors are encountered in the client while making the
* request or handling the response.
* @throws AmazonServiceException
* If any errors occurred in Amazon S3 while processing the
* request.
*
* @see Region
*/
public String getBucketLocation(GetBucketLocationRequest getBucketLocationRequest)
throws AmazonClientException, AmazonServiceException;
/**
* <p>
* Creates a new Amazon S3 bucket in the default
* region, {@link Region#US_Standard}.
* </p>
* <p>
* Every object stored in Amazon S3 is contained within a bucket. Buckets
* partition the namespace of objects stored in Amazon S3 at the top level.
* Within a bucket, any name can be used for objects. However, bucket names
* must be unique across all of Amazon S3.
* </p>
* <p>
* Bucket ownership is similar to the ownership of Internet domain names.
* Within Amazon S3, only a single user owns each bucket.
* Once a uniquely named bucket is created in Amazon S3,
* organize and name the objects within the bucket in any way.
* Ownership of the bucket is retained as long as the owner has an Amazon S3 account.
* </p>
* <p>
* To conform with DNS requirements, the following constraints apply:
* <ul>
* <li>Bucket names should not contain underscores</li>
* <li>Bucket names should be between 3 and 63 characters long</li>
* <li>Bucket names should not end with a dash</li>
* <li>Bucket names cannot contain adjacent periods</li>
* <li>Bucket names cannot contain dashes next to periods (e.g.,
* "my-.bucket.com" and "my.-bucket" are invalid)</li>
* <li>Bucket names cannot contain uppercase characters</li>
* </ul>
* </p>
* <p>
* There are no limits to the number of objects that can be stored in a bucket.
* Performance does not vary based on the number of buckets used. Store
* all objects within a single bucket or organize them across several buckets.
* </p>
* <p>
* Buckets cannot be nested; buckets cannot be created within
* other buckets.
* </p>
* <p>
* Do not make bucket
* create or delete calls in the high availability code path of an
* application. Create or delete buckets in a separate
* initialization or setup routine that runs less often.
* </p>
* <p>
* To create a bucket, authenticate with an account that has a
* valid AWS Access Key ID and is registered with Amazon S3. Anonymous
* requests are never allowed to create buckets.
* </p>
*
* @param createBucketRequest
* The request object containing all options for creating an Amazon S3