@@ -77,12 +77,12 @@ impl ReportWriter for S3Writer {
77
77
fn write_bytes < P : AsRef < Path > > (
78
78
& self ,
79
79
path : P ,
80
- s : Vec < u8 > ,
80
+ body : & [ u8 ] ,
81
81
mime : & Mime ,
82
82
encoding_type : EncodingType ,
83
83
) -> Fallible < ( ) > {
84
84
// At least 50 MB, then use a multipart upload...
85
- if s . len ( ) >= 50 * 1024 * 1024 {
85
+ if body . len ( ) >= 50 * 1024 * 1024 {
86
86
let mut request = self
87
87
. client
88
88
. create_multipart_upload ( )
@@ -108,12 +108,12 @@ impl ReportWriter for S3Writer {
108
108
} ;
109
109
110
110
let chunk_size = 20 * 1024 * 1024 ;
111
- let bytes = bytes:: Bytes :: from ( s) ;
112
111
let mut part = 1 ;
113
112
let mut start = 0 ;
114
113
let mut parts = aws_sdk_s3:: types:: CompletedMultipartUpload :: builder ( ) ;
115
- while start < bytes. len ( ) {
116
- let chunk = bytes. slice ( start..std:: cmp:: min ( start + chunk_size, bytes. len ( ) ) ) ;
114
+ while start < body. len ( ) {
115
+ let chunk = & body[ start..std:: cmp:: min ( start + chunk_size, body. len ( ) ) ] ;
116
+ let chunk = bytes:: Bytes :: copy_from_slice ( chunk) ;
117
117
118
118
let request = self
119
119
. client
@@ -160,7 +160,9 @@ impl ReportWriter for S3Writer {
160
160
let mut request = self
161
161
. client
162
162
. put_object ( )
163
- . body ( aws_sdk_s3:: primitives:: ByteStream :: from ( s) )
163
+ . body ( aws_sdk_s3:: primitives:: ByteStream :: from (
164
+ bytes:: Bytes :: copy_from_slice ( body) ,
165
+ ) )
164
166
. acl ( aws_sdk_s3:: types:: ObjectCannedAcl :: PublicRead )
165
167
. key ( format ! (
166
168
"{}/{}" ,
@@ -185,7 +187,7 @@ impl ReportWriter for S3Writer {
185
187
}
186
188
187
189
fn write_string < P : AsRef < Path > > ( & self , path : P , s : Cow < str > , mime : & Mime ) -> Fallible < ( ) > {
188
- self . write_bytes ( path, s. into_owned ( ) . into_bytes ( ) , mime, EncodingType :: Plain )
190
+ self . write_bytes ( path, s. as_bytes ( ) , mime, EncodingType :: Plain )
189
191
}
190
192
}
191
193
0 commit comments