forked from aws/aws-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPutObjectRequest.java
More file actions
850 lines (798 loc) · 30.3 KB
/
PutObjectRequest.java
File metadata and controls
850 lines (798 loc) · 30.3 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
/*
* 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.model;
import java.io.File;
import java.io.InputStream;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.event.ProgressListener;
/**
* <p>
* Uploads a new object to the specified Amazon S3 bucket.
* The PutObjectRequest optionally uploads object metadata
* and applies a canned access
* control policy to the new object.
* </p>
* <p>
* Amazon S3 never stores partial objects;
* if during this call an exception wasn't thrown,
* the entire object was stored.
* </p>
* <p>
* Depending on whether a file or input stream is being uploaded, this
* request has slightly different behavior.
* </p>
* <p>
* When uploading a file:
* </p>
* <ul>
* <li>
* The client automatically computes a checksum of the file.
* Amazon S3 uses checksums to validate the data in each file.
* </li>
* <li>
* Using the file extension, Amazon S3 attempts to determine
* the correct content type and content disposition to use
* for the object.
* </li>
* </ul>
* <p>
* When uploading directly from an input stream, content length <b>must</b> be specified before data can be uploaded
* to Amazon S3. If not provided, the library will <b>have
* to</b> buffer the contents of the input stream in order to calculate it.
* Amazon S3 explicitly requires that the content length be sent in
* the request headers before any of the data is sent.</li>
* <p>
* Amazon S3 is a distributed system. If
* Amazon S3 receives multiple write requests for the same object nearly
* simultaneously, all of the objects might be stored. However, only one object
* will obtain the key.
* </p>
* <p>
* Note: Amazon S3 does not provide object locking; if this is needed, make
* sure to build it into the application layer.
* </p>
* <p>
* If the caller specifies a location constraint when creating a bucket,
* all objects added to the bucket are stored in the same region as the bucket.
* For example, if specifying a Europe (EU) region constraint for a bucket,
* all of that bucket's objects are stored in the EU region.
* </p>
* <p>
* The specified bucket must already exist and the caller must have
* {@link Permission#Write} permission to the bucket to upload an object.
* </p>
*
* @see PutObjectRequest#PutObjectRequest(String, String, File)
* @see PutObjectRequest#PutObjectRequest(String, String, InputStream, ObjectMetadata)
*/
public class PutObjectRequest extends AmazonWebServiceRequest {
/**
* The name of an existing bucket, to which this request will upload a new
* object. You must have {@link Permission#Write} permission granted to you
* in order to upload new objects to a bucket.
*/
private String bucketName;
/**
* The key under which to store the new object.
*/
private String key;
/**
* The file containing the data to be uploaded to Amazon S3. You must either
* specify a file or an InputStream containing the data to be uploaded to
* Amazon S3.
*/
private File file;
/**
* The InputStream containing the data to be uploaded to Amazon S3. You must
* either specify a file or an InputStream containing the data to be
* uploaded to Amazon S3.
*/
private InputStream inputStream;
/**
* Optional metadata instructing Amazon S3 how to handle the uploaded data
* (e.g. custom user metadata, hooks for specifying content type, etc.). If
* you are uploading from an InputStream, you <bold>should always</bold>
* specify metadata with the content size set, otherwise the contents of the
* InputStream will have to be buffered in memory before they can be sent to
* Amazon S3, which can have very negative performance impacts.
*/
private ObjectMetadata metadata;
/**
* An optional pre-configured access control policy to use for the new
* object. Ignored in favor of accessControlList, if present.
*/
private CannedAccessControlList cannedAcl;
/**
* An optional access control list to apply to the new object. If specified,
* cannedAcl will be ignored.
*/
private AccessControlList accessControlList;
/**
* The optional Amazon S3 storage class to use when storing the new object.
* If not specified, the default, standard storage class will be used.
* <p>
* For more information on Amazon S3 storage classes and available values,
* see the {@link StorageClass} enumeration.
*/
private String storageClass;
/**
* The optional progress listener for receiving updates about object download
* status.
*/
private ProgressListener generalProgressListener;
/** The optional redirect location about an object */
private String redirectLocation;
/**
* Constructs a new
* {@link PutObjectRequest} object to upload a file to the
* specified bucket and key. After constructing the request,
* users may optionally specify object metadata or a canned ACL as well.
*
* @param bucketName
* The name of an existing bucket to which the new object will be
* uploaded.
* @param key
* The key under which to store the new object.
* @param file
* The path of the file to upload to Amazon S3.
*
* @see PutObjectRequest#PutObjectRequest(String, String, InputStream, ObjectMetadata)
* @See PutObjectRequest(String bucketName, String key, String redirectLocation)
*/
public PutObjectRequest(String bucketName, String key, File file) {
this.bucketName = bucketName;
this.key = key;
this.file = file;
}
/**
* Constructs a new {@link PutObjectRequest} object with redirect location.
* After constructing the request, users may optionally specify object
* metadata or a canned ACL as well.
*
* @param bucketName
* The name of an existing bucket to which the new object will be
* uploaded.
* @param key
* The key under which to store the new object.
* @param redirectLocation
* The redirect location of this new object.
*
* @see PutObjectRequest#PutObjectRequest(String, String, InputStream, ObjectMetadata)
* @see PutObjectRequest#PutObjectRequest(String, String, File)
*/
public PutObjectRequest(String bucketName, String key, String redirectLocation) {
this.bucketName = bucketName;
this.key = key;
this.redirectLocation = redirectLocation;
}
/**
* Constructs a new
* {@link PutObjectRequest} object to upload a stream of data to
* the specified bucket and key. After constructing the request,
* users may optionally specify object metadata or a canned ACL as well.
* <p>
* Content length for the data stream <b>must</b> be
* specified in the object metadata parameter; Amazon S3 requires it
* be passed in before the data is uploaded. Failure to specify a content
* length will cause the entire contents of the input stream to be buffered
* locally in memory so that the content length can be calculated, which can
* result in negative performance problems.
* </p>
*
* @param bucketName
* The name of an existing bucket to which the new object will be
* uploaded.
* @param key
* The key under which to store the new object.
* @param input
* The stream of data to upload to Amazon S3.
* @param metadata
* The object metadata. At minimum this specifies the
* content length for the stream of data being uploaded.
*
* @see PutObjectRequest#PutObjectRequest(String, String, File)
* @see PutObjectRequest(String bucketName, String key, String redirectLocation)
*/
public PutObjectRequest(String bucketName, String key, InputStream input, ObjectMetadata metadata) {
this.bucketName = bucketName;
this.key = key;
this.inputStream = input;
this.metadata = metadata;
}
/**
* Gets the name of the existing bucket where this request will
* upload a new object to.
* In order to upload the object,
* users must have {@link Permission#Write} permission granted.
*
* @return The name of an existing bucket where this request will
* upload a new object to.
*
* @see PutObjectRequest#setBucketName(String)
* @see PutObjectRequest#withBucketName(String)
*/
public String getBucketName() {
return bucketName;
}
/**
* Sets the name of an existing bucket where this request will
* upload a new object to. In order to upload the object,
* users must have {@link Permission#Write} permission granted.
*
* @param bucketName
* The name of an existing bucket where this request will
* upload a new object to.
* In order to upload the object,
* users must have {@link Permission#Write} permission granted.
*
* @see PutObjectRequest#getBucketName()
* @see PutObjectRequest#withBucketName(String)
*/
public void setBucketName(String bucketName) {
this.bucketName = bucketName;
}
/**
* Sets the name of the bucket where this request will upload a new
* object to. Returns this object, enabling additional method calls to be
* chained together.
* <p>
* In order to upload the object,
* users must have {@link Permission#Write} permission granted.
*
* @param bucketName
* The name of an existing bucket where this request will
* upload a new object to.
* In order to upload the object,
* users must have {@link Permission#Write} permission granted.
*
* @return This {@link PutObjectRequest}, enabling additional method calls to be
* chained together.
*
* @see PutObjectRequest#getBucketName()
* @see PutObjectRequest#setBucketName(String)
*/
public PutObjectRequest withBucketName(String bucketName) {
setBucketName(bucketName);
return this;
}
/**
* Gets the key under which to store the new object.
*
* @return The key under which to store the new object.
*
* @see PutObjectRequest#setKey(String)
* @see PutObjectRequest#withKey(String)
*/
public String getKey() {
return key;
}
/**
* Sets the key under which to store the new object.
*
* @param key
* The key under which to store the new object.
*
* @see PutObjectRequest#getKey()
* @see PutObjectRequest#withKey(String)
*/
public void setKey(String key) {
this.key = key;
}
/**
* Sets the key under which to store the new object. Returns this object,
* enabling additional method calls to be chained together.
*
* @param key
* The key under which to store the new object.
*
* @return This {@link PutObjectRequest}, enabling additional method calls to be
* chained together.
*
* @see PutObjectRequest#getKey()
* @see PutObjectRequest#setKey(String)
*/
public PutObjectRequest withKey(String key) {
setKey(key);
return this;
}
/**
* Gets the optional Amazon S3 storage class to use when storing the new
* object. If not specified, the default standard storage class is
* used when storing the object.
* <p>
* For more information on available Amazon S3 storage classes, see the
* {@link StorageClass} enumeration.
* </p>
*
* @return The Amazon S3 storage class to use when storing the newly copied
* object.
*
* @see PutObjectRequest#setStorageClass(String)
* @see PutObjectRequest#setStorageClass(StorageClass)
* @see PutObjectRequest#withStorageClass(StorageClass)
* @see PutObjectRequest#withStorageClass(String)
*/
public String getStorageClass() {
return storageClass;
}
/**
* Sets the optional Amazon S3 storage class to use when storing the new
* object. If not specified, the default standard storage class will be
* used when storing the new object.
* <p>
* For more information on Amazon S3 storage classes and available values,
* see the {@link StorageClass} enumeration.
* </p>
*
* @param storageClass
* The storage class to use when storing the new object.
*
* @return The Amazon S3 storage class to use when storing the newly copied
* object.
*
* @see PutObjectRequest#getStorageClass()
* @see PutObjectRequest#setStorageClass(StorageClass
* @see PutObjectRequest#withStorageClass(StorageClass)
* @see PutObjectRequest#withStorageClass(String)
*/
public void setStorageClass(String storageClass) {
this.storageClass = storageClass;
}
/**
* Sets the optional Amazon S3 storage class to use when storing the new
* object. Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together. If not specified, the default standard
* storage class will be used when storing the object.
* <p>
* For more information on Amazon S3 storage classes and available values,
* see the {@link StorageClass} enumeration.
* </p>
*
* @param storageClass
* The storage class to use when storing the new object.
*
* @return This {@link PutObjectRequest}, enabling additional method calls to be
* chained together.
*
* @see PutObjectRequest#getStorageClass()
* @see PutObjectRequest#setStorageClass(StorageClass)
* @see PutObjectRequest#setStorageClass(String)
* @see PutObjectRequest#withStorageClass(StorageClass)
*/
public PutObjectRequest withStorageClass(String storageClass) {
setStorageClass(storageClass);
return this;
}
/**
* Sets the optional Amazon S3 storage class to use when storing the new
* object. If not specified, the default standard storage class will be
* used when storing the object.
* <p>
* For more information on Amazon S3 storage classes and available values,
* see the {@link StorageClass} enumeration.
* </p>
*
* @param storageClass
* The storage class to use when storing the new object.
*
* @return The Amazon S3 storage class to use when storing the newly copied
* object.
*
* @see PutObjectRequest#getStorageClass()
* @see PutObjectRequest#setStorageClass(String)
*/
public void setStorageClass(StorageClass storageClass) {
this.storageClass = storageClass.toString();
}
/**
* Sets the optional Amazon S3 storage class to use when storing the new
* object. Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together. If not specified, the default standard
* storage class will be used when storing the object.
* <p>
* For more information on Amazon S3 storage classes and available values,
* see the {@link StorageClass} enumeration.
* </p>
*
* @param storageClass
* The storage class to use when storing the new object.
*
* @return This {@link PutObjectRequest}, enabling additional method calls to be
* chained together.
*
* @see PutObjectRequest#getStorageClass()
* @see PutObjectRequest#setStorageClass(StorageClass)
* @see PutObjectRequest#setStorageClass(String)
* @see PutObjectRequest#withStorageClass(String)
*/
public PutObjectRequest withStorageClass(StorageClass storageClass) {
setStorageClass(storageClass);
return this;
}
/**
* Gets the path and name of the file
* containing the data to be uploaded to Amazon S3.
* Either specify a file or an input stream containing the data to be
* uploaded to Amazon S3; both cannot be specified.
*
* @return The path and name of the file
* containing the data to be uploaded to Amazon S3.
*
* @see PutObjectRequest#setFile(File)
* @see PutObjectRequest#withFile(File)
* @see PutObjectRequest#setInputStream(InputStream)
* @see PutObjectRequest#withInputStream(InputStream)
*/
public File getFile() {
return file;
}
/**
* Sets the path and name of the file
* containing the data to be uploaded to Amazon S3.
* Either specify a file or an input stream containing the data to be
* uploaded to Amazon S3; both cannot be specified.
*
* @param file
* The path and name of the
* file containing the data to be uploaded to Amazon S3.
*
* @see PutObjectRequest#getFile()
* @see PutObjectRequest#withFile(File)
* @see PutObjectRequest#getInputStream()
* @see PutObjectRequest#withInputStream(InputStream)
*/
public void setFile(File file) {
this.file = file;
}
/**
* Sets the file containing the data to be uploaded to Amazon S3.
* Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
* <p>
* Either specify a file or an input stream containing the data to
* be uploaded to Amazon S3; both cannot be specified.
*
* @param file
* The file containing the data to be uploaded to Amazon S3.
*
* @return This {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
*
* @see PutObjectRequest#getFile()
* @see PutObjectRequest#setFile(File)
* @see PutObjectRequest#getInputStream()
* @see PutObjectRequest#setInputStream(InputStream)
*/
public PutObjectRequest withFile(File file) {
setFile(file);
return this;
}
/**
* Gets the optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying content
* type, etc.).
* <p>
* If uploading from an input stream,
* <b>always</b> specify metadata with the content size set. Otherwise the
* contents of the input stream have to be buffered in memory before
* being sent to Amazon S3. This can cause very negative performance
* impacts.
* </p>
*
* @return The optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying
* content type, etc.).
*
* @see PutObjectRequest#setMetadata(ObjectMetadata)
* @see PutObjectRequest#withMetadata(ObjectMetadata)
*/
public ObjectMetadata getMetadata() {
return metadata;
}
/**
* Sets the optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying content
* type, etc.).
* <p>
* If uploading from an input stream,
* <b>always</b> specify metadata with the content size set. Otherwise the
* contents of the input stream have to be buffered in memory before
* being sent to Amazon S3. This can cause very negative performance
* impacts.
* </p>
*
* @param metadata
* The optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying
* content type, etc.).
*
* @see PutObjectRequest#getMetadata()
* @see PutObjectRequest#withMetadata(ObjectMetadata)
*/
public void setMetadata(ObjectMetadata metadata) {
this.metadata = metadata;
}
/**
* Sets the optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying content
* type, etc.). Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
* <p>
* If uploading from an input stream,
* <b>always</b> specify metadata with the content size set. Otherwise the
* contents of the input stream have to be buffered in memory before
* being sent to Amazon S3. This can cause very negative performance
* impacts.
* </p>
*
* @param metadata
* The optional metadata instructing Amazon S3 how to handle the
* uploaded data (e.g. custom user metadata, hooks for specifying
* content type, etc.).
*
* @return This {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
*
* @see PutObjectRequest#getMetadata()
* @see PutObjectRequest#setMetadata(ObjectMetadata)
*/
public PutObjectRequest withMetadata(ObjectMetadata metadata) {
setMetadata(metadata);
return this;
}
/**
* Gets the optional pre-configured access control policy to use for the
* new object.
*
* @return The optional pre-configured access control policy to use for the
* new object.
*
* @see PutObjectRequest#setCannedAcl(CannedAccessControlList)
* @see PutObjectRequest#withCannedAcl(CannedAccessControlList)
*/
public CannedAccessControlList getCannedAcl() {
return cannedAcl;
}
/**
* Sets the optional pre-configured access control policy to use for the new
* object.
*
* @param cannedAcl
* The optional pre-configured access control policy to use for
* the new object.
*
* @see PutObjectRequest#getCannedAcl()
* @see PutObjectRequest#withCannedAcl(CannedAccessControlList)
*/
public void setCannedAcl(CannedAccessControlList cannedAcl) {
this.cannedAcl = cannedAcl;
}
/**
* Sets the optional pre-configured access control policy to use for the new
* object. Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
*
* @param cannedAcl
* The optional pre-configured access control policy to use for
* the new object.
*
* @return This {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
*
* @see PutObjectRequest#getCannedAcl()
* @see PutObjectRequest#setCannedAcl(CannedAccessControlList)
*/
public PutObjectRequest withCannedAcl(CannedAccessControlList cannedAcl) {
setCannedAcl(cannedAcl);
return this;
}
/**
* Returns the optional access control list for the new object. If
* specified, cannedAcl will be ignored.
*/
public AccessControlList getAccessControlList() {
return accessControlList;
}
/**
* Sets the optional access control list for the new object. If specified,
* cannedAcl will be ignored.
*
* @param accessControlList
* The access control list for the new object.
*/
public void setAccessControlList(AccessControlList accessControlList) {
this.accessControlList = accessControlList;
}
/**
* Sets the optional access control list for the new object. If specified,
* cannedAcl will be ignored. Returns this {@link PutObjectRequest},
* enabling additional method calls to be chained together.
*
* @param accessControlList
* The access control list for the new object.
*/
public PutObjectRequest withAccessControlList(AccessControlList accessControlList) {
setAccessControlList(accessControlList);
return this;
}
/**
* Gets the input stream containing the data to be uploaded to Amazon S3.
* The user of this request
* must either specify a file or an input stream containing the data to be
* uploaded to Amazon S3; both cannot be specified.
*
* @return The input stream containing the data to be uploaded to Amazon S3.
* Either specify a file or an input stream containing the
* data to be uploaded to Amazon S3, not both.
*
* @see PutObjectRequest#setInputStream(InputStream)
* @see PutObjectRequest#withInputStream(InputStream)
* @see PutObjectRequest#setFile(File)
* @see PutObjectRequest#withFile(File)
*/
public InputStream getInputStream() {
return inputStream;
}
/**
* Sets the input stream containing the data to be uploaded to Amazon S3.
* Either specify a file or an input stream containing the data to be
* uploaded to Amazon S3; both cannot be specified.
*
* @param inputStream
* The input stream containing the data to be uploaded to Amazon
* S3. Either specify a file or an input stream containing the
* data to be uploaded to Amazon S3, not both.
*
* @see PutObjectRequest#getInputStream()
* @see PutObjectRequest#withInputStream(InputStream)
* @see PutObjectRequest#getFile()
* @see PutObjectRequest#withFile(File)
*/
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
/**
* Sets the input stream containing the data to be uploaded to Amazon S3.
* Returns this {@link PutObjectRequest}, enabling additional method
* calls to be chained together.
* <p>
* Either specify a file or an input stream containing the data to be
* uploaded to Amazon S3; both cannot be specified.
* </p>
*
* @param inputStream
* The InputStream containing the data to be uploaded to Amazon
* S3.
*
* @return This PutObjectRequest, so that additional method calls can be
* chained together.
*
* @see PutObjectRequest#getInputStream()
* @see PutObjectRequest#setInputStream(InputStream)
* @see PutObjectRequest#getFile()
* @see PutObjectRequest#setFile(File)
*/
public PutObjectRequest withInputStream(InputStream inputStream) {
setInputStream(inputStream);
return this;
}
/**
* Sets the optional redirect location for the new object.
*
* @param redirectLocation
* The redirect location for the new object.
*/
public void setRedirectLocation(String redirectLocation) {
this.redirectLocation = redirectLocation;
}
/**
* Gets the optional redirect location for the new object.
*/
public String getRedirectLocation() {
return this.redirectLocation;
}
/**
* Sets the optional redirect location for the new object.Returns this
* {@link PutObjectRequest}, enabling additional method calls to be chained
* together.
* @param redirectLocation
* The redirect location for the new object.
*/
public PutObjectRequest withRedirectLocation(String redirectLocation) {
this.redirectLocation = redirectLocation;
return this;
}
/**
* Sets the optional progress listener for receiving updates for object
* upload status.
*
* @param progressListener
* The legacy progress listener that is used exclusively for Amazon S3 client.
*
* @deprecated use {@link #setGeneralProgressListener(ProgressListener)} instead.
*/
@Deprecated
public void setProgressListener(com.amazonaws.services.s3.model.ProgressListener progressListener) {
this.generalProgressListener = new LegacyS3ProgressListener(progressListener);
}
/**
* Returns the optional progress listener for receiving updates about object
* upload status.
*
* @return the optional progress listener for receiving updates about object
* upload status.
*
* @deprecated use {@link #getGeneralProgressListener()} instead.
*/
@Deprecated
public com.amazonaws.services.s3.model.ProgressListener getProgressListener() {
if (generalProgressListener instanceof LegacyS3ProgressListener) {
return ((LegacyS3ProgressListener)generalProgressListener).unwrap();
} else {
return null;
}
}
/**
* Sets the optional progress listener for receiving updates about object
* upload status, and returns this updated object so that additional method
* calls can be chained together.
*
* @param progressListener
* The legacy progress listener that is used exclusively for Amazon S3 client.
*
* @return This updated PutObjectRequest object.
*
* @deprecated use {@link #withGeneralProgressListener(ProgressListener)} instead.
*/
@Deprecated
public PutObjectRequest withProgressListener(com.amazonaws.services.s3.model.ProgressListener progressListener) {
setProgressListener(progressListener);
return this;
}
/**
* Sets the optional progress listener for receiving updates about object
* download status.
*
* @param generalProgressListener
* The new progress listener.
*/
public void setGeneralProgressListener(ProgressListener generalProgressListener) {
this.generalProgressListener = generalProgressListener;
}
/**
* Returns the optional progress listener for receiving updates about object
* download status.
*
* @return the optional progress listener for receiving updates about object
* download status.
*/
public ProgressListener getGeneralProgressListener() {
return generalProgressListener;
}
/**
* Sets the optional progress listener for receiving updates about object
* upload status, and returns this updated object so that additional method
* calls can be chained together.
*
* @param generalProgressListener
* The new progress listener.
*
* @return This updated PutObjectRequest object.
*/
public PutObjectRequest withGeneralProgressListener(ProgressListener generalProgressListener) {
setGeneralProgressListener(generalProgressListener);
return this;
}
}