@@ -116,7 +116,7 @@ public SFS3Client(
116116 stageInfo . endPoint ,
117117 maxRetry ,
118118 parallel ) ;
119-
119+
120120 // Get the AWS token value and create the S3 client
121121 if ( stageInfo . stageCredentials . TryGetValue ( AWS_TOKEN , out string awsSessionToken ) )
122122 {
@@ -164,7 +164,7 @@ public RemoteLocation ExtractBucketNameAndPath(string stageLocation)
164164 {
165165 bucketName = stageLocation . Substring ( 0 , stageLocation . IndexOf ( '/' ) ) ;
166166
167- s3path = stageLocation . Substring ( stageLocation . IndexOf ( '/' ) + 1 ,
167+ s3path = stageLocation . Substring ( stageLocation . IndexOf ( '/' ) + 1 ,
168168 stageLocation . Length - stageLocation . IndexOf ( '/' ) - 1 ) ;
169169 if ( s3path != null && ! s3path . EndsWith ( "/" ) )
170170 {
@@ -287,13 +287,13 @@ private FileHeader HandleFileHeaderResponse(ref SFFileMetadata fileMetadata, Get
287287 }
288288
289289 /// <summary>
290- /// Set the client configuration common to both client with and without client-side
290+ /// Set the client configuration common to both client with and without client-side
291291 /// encryption.
292292 /// </summary>
293293 /// <param name="clientConfig">The client config to update.</param>
294294 /// <param name="region">The region if any.</param>
295295 /// <param name="endpoint">The endpoint if any.</param>
296- private static void SetCommonClientConfig (
296+ internal static void SetCommonClientConfig (
297297 AmazonS3Config clientConfig ,
298298 string region ,
299299 string endpoint ,
@@ -309,23 +309,25 @@ private static void SetCommonClientConfig(
309309 }
310310
311311 // If a specific endpoint is specified use this
312- if ( ( null != endpoint ) && ( 0 != endpoint . Length ) )
312+ if ( ! string . IsNullOrEmpty ( endpoint ) )
313313 {
314314 var start = endpoint . IndexOf ( '[' ) ;
315315 var end = endpoint . IndexOf ( ']' ) ;
316- if ( start > - 1 && end > - 1 && end > start )
316+ if ( start > - 1 && end > - 1 && end > start )
317317 {
318318 endpoint = endpoint . Substring ( start + 1 , end - start - 1 ) ;
319- if ( ! endpoint . Contains ( "https" ) )
320- {
321- endpoint = "https://" + endpoint ;
322- }
323319 }
320+
321+ if ( ! endpoint . StartsWith ( "https://" , StringComparison . OrdinalIgnoreCase ) )
322+ {
323+ endpoint = "https://" + endpoint ;
324+ }
325+
324326 clientConfig . ServiceURL = endpoint ;
325327 }
326328
327329 // The region information used to determine the endpoint for the service.
328- // RegionEndpoint and ServiceURL are mutually exclusive properties.
330+ // RegionEndpoint and ServiceURL are mutually exclusive properties.
329331 // If both stageInfo.endPoint and stageInfo.region have a value, stageInfo.region takes
330332 // precedence and ServiceUrl will be reset to null.
331333 if ( ( null != region ) && ( 0 != region . Length ) )
@@ -337,7 +339,6 @@ private static void SetCommonClientConfig(
337339 // Unavailable for .net framework 4.6
338340 //clientConfig.MaxConnectionsPerServer = parallel;
339341 clientConfig . MaxErrorRetry = maxRetry ;
340-
341342 }
342343
343344 /// <summary>
@@ -410,7 +411,7 @@ private PutObjectRequest GetPutObjectRequest(ref AmazonS3Client client, SFFileMe
410411 {
411412 PutGetStageInfo stageInfo = fileMetadata . stageInfo ;
412413 RemoteLocation location = ExtractBucketNameAndPath ( stageInfo . location ) ;
413-
414+
414415 // Create S3 PUT request
415416 fileBytesStream . Position = 0 ;
416417 PutObjectRequest putObjectRequest = new PutObjectRequest
@@ -585,4 +586,4 @@ private SFFileMetadata HandleDownloadFileErr(Exception ex, SFFileMetadata fileMe
585586 return fileMetadata ;
586587 }
587588 }
588- }
589+ }
0 commit comments