First is POM rely on
& lt; Dependency>Com. Amazonaws Aws - Java - SDK - s3 & lt;/artifactId> 1.11.233 & lt;/version>
Then the code
@ Test
Public void testUploadObject2 () {
S3Client=AmazonS3ClientBuilder. Standard ()
WithCredentials (new AWSStaticCredentialsProvider (new BasicAWSCredentials (the accessKey, secretKey)))
WithEndpointConfiguration (new AwsClientBuilder. EndpointConfiguration (s3Endpoint, Regions. US_EAST_1. GetName ()))
.build();
String bucketName="migc2021";
The String key="upload";
The File File=new File (" D: \ \ test. JPG ");
S3Client. PutObject (bucketName, key, file).
}
The mistake is
Com. Amazonaws. Services. S3. Model. AmazonS3Exception: The Content - MD5 you specified did not match what we received (Service: Amazon s3; The Status Code: 400; The Error Code: BadDigest; The Request ID:/migc2021/upload; S3 Extended Request ID: null)
, the S3 Extended Request ID: null
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. HandleErrorResponse (AmazonHttpClient. Java: 1639)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. ExecuteOneRequest (AmazonHttpClient. Java: 1304)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. ExecuteHelper (AmazonHttpClient. Java: 1056)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. The doExecute (AmazonHttpClient. Java: 743)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. ExecuteWithTimer (AmazonHttpClient. Java: 717)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. Execute (AmazonHttpClient. Java: 699)
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutor. Access the $500 (667) AmazonHttpClient. Java:
At com. Amazonaws. HTTP. AmazonHttpClient $RequestExecutionBuilderImpl. Execute (AmazonHttpClient. Java: 649)
At com. Amazonaws. HTTP. AmazonHttpClient. Execute (AmazonHttpClient. Java: 513)
At com. Amazonaws. Services. S3. AmazonS3Client. Invoke (AmazonS3Client. Java: 4319)
At com. Amazonaws. Services. S3. AmazonS3Client. Invoke (AmazonS3Client. Java: 4266)
At com. Amazonaws. Services. S3. AmazonS3Client. PutObject (AmazonS3Client. Java: 1746)
At com. Amazonaws. Services. S3. AmazonS3Client. PutObject (AmazonS3Client. Java: 1601)
At com. Sp. Jwt_demo. Utils. S3Test. TestUploadObject2 (S3Test. Java: 156)
The at Java. The base/JDK. Internal. Reflect. NativeMethodAccessorImpl. Invoke0 (Native Method)
The at Java. The base/JDK. Internal. Reflect. NativeMethodAccessorImpl. Invoke (NativeMethodAccessorImpl. Java: 62)
The at Java. The base/JDK. Internal. Reflect. DelegatingMethodAccessorImpl. Invoke (43) DelegatingMethodAccessorImpl. Java:
The at Java. The base/Java. Lang. Reflect. Method. Invoke (566) Method. The Java:
The at org. Junit. Runners. Model. FrameworkMethod $1. RunReflectiveCall (FrameworkMethod. Java: 50)
The at org. Junit. Internal. Runners. Model. ReflectiveCallable. Run (ReflectiveCallable. Java: 12)
The at org. Junit. Runners. Model. FrameworkMethod. InvokeExplosively (FrameworkMethod. Java: 47)
The at org. Junit. Internal. Runners. Statements. InvokeMethod. Evaluate (InvokeMethod. Java: 17)
The at org. Junit. Runners. ParentRunner. RunLeaf (ParentRunner. Java: 325)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 78)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 57)
The at org. Junit. Runners. ParentRunner $3. The run (ParentRunner. Java: 290)
The at org. Junit. Runners. ParentRunner $1. The schedule (ParentRunner. Java: 71)
The at org. Junit. Runners. ParentRunner. RunChildren (ParentRunner. Java: 288)
The at org. Junit. Runners. ParentRunner. Access the $000 (ParentRunner. Java: 58)
At org. Junit. Runners. ParentRunner $2. The evaluate (ParentRunner. Java: 268)
The at org. Junit. Runners. ParentRunner. Run (ParentRunner. Java: 363)
The at org. Junit. Runner. JUnitCore. Run (JUnitCore. Java: 137)
At com. Intellij. Takeup. JUnit4IdeaTestRunner. StartRunnerWithArgs (JUnit4IdeaTestRunner. Java: 69)
At com. Intellij. Rt. Junit. IdeaTestRunner $Repeater. StartRunnerWithArgs (IdeaTestRunner. Java: 33)
At com. Intellij. Rt. Junit. JUnitStarter. PrepareStreamsAndStart (JUnitStarter. Java: 220)
At com. Intellij. Rt. Junit. JUnitStarter. Main (53) JUnitStarter. Java:
Check the S3, what folder are some, for bosses,