Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

360
Views
unable to upload files to S3 through jmeter

I am trying to upload files to S3 through PUT http request from jmeter. I am specifying the URL in the 'Path' and 'file path and mime type in the 'Files upload' section.

I get 'Access Denied' response from S3. The same URL works fine through Postman and the upload succeeds.

Any help on this??

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Given you are able to successfully upload the file using Postman you can just record the associated request using JMeter.

  1. Prepare JMeter for recording. The fastest and the easiest way is using JMeter Templates feature. From JMeter's main menu choose File - Templates - Recording and click "Create

    JMeter Proxy Template

  2. Expand Workbench - HTTP(S) Test Script Recorder and click "Start" button

    JMeter Start Proxy

  3. Run Postman using JMeter as proxy server like:

    C:\Users\Jayashree\AppData\Local\Postman\app-4.9.3\Postman.exe --proxy-server=localhost:8888
    
  4. Put the file you need to upload to the "bin" folder of your JMeter installation
  5. Run the request in Postman - JMeter should record it under Test Plan - Thread Group - Recording Controller

See HTTP(S) Test Script Recorder documentation for more information.

over 4 years ago · Santiago Trujillo Report

0

Have you properly specified the AWS credentials in the JMeter PUT request ? You need to specify AWS Access Key and secret key.

Another solution would be to use the AWS Java SDK from a JSR223 sampler, and make the call using Java code.

over 4 years ago · Santiago Trujillo Report

0

I have mentioned the steps to upload an image to s3 bucket using JMeter below:

Requirements:

  • Java 9
  • aws-java-sdk-s3 JAR 1.11.313 dependencies link

Steps:

  • Copy the jar files to JMeterHome/lib/ext/ of Jmeter.

  • Create a Test Plan and click on Thread Group.

  • Set Number of Threads, Ramp-up period and Loop Count to 1.

  • Right click on thread groups and add a JSR233 sampler.

  • Select Java as the language in the JSR233 sampler.

  • Add the following code in the script section of the sampler.

     import java.io.IOException;
     import java.io.InputStream;
     import java.util.Properties;
     import java.util.ArrayList;
     import java.util.List;
     import java.util.Scanner;
     import com.amazonaws.auth.AWSSessionCredentials;
     import com.amazonaws.auth.AWSStaticCredentialsProvider;
     import com.amazonaws.auth.BasicAWSCredentials;
     import com.amazonaws.services.s3.AmazonS3;
     import com.amazonaws.services.s3.AmazonS3ClientBuilder;
     import com.amazonaws.services.s3.model.AmazonS3Exception;
     import com.amazonaws.services.s3.model.GetObjectRequest;
     import com.amazonaws.services.s3.model.PutObjectRequest;
     import com.amazonaws.services.s3.model.PutObjectResult;
     import com.amazonaws.services.s3.model.S3Object;
     import com.amazonaws.services.s3.model.S3ObjectInputStream;
     import com.amazonaws.regions.Regions;
     import com.amazonaws.regions.Region;
     import com.amazonaws.services.s3.model.ObjectMetadata;
     import com.amazonaws.services.s3.transfer.Download;
     import com.amazonaws.services.s3.transfer.TransferManager;
     import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
     import com.amazonaws.services.s3.transfer.Upload;
    
     String accessKey = "xxxxxxx";
     String secretKey = "xxxxxxxxx";               
     String bucketName = "bucketname"; //specify bucketname
     String region = "region"; //specify region
    
     BasicAWSCredentials sessionCredentials = new BasicAWSCredentials(accessKey, secretKey);
    
     AmazonS3 s3 = AmazonS3ClientBuilder.standard()
    .withRegion(region)
    .withCredentials(new AWSStaticCredentialsProvider(sessionCredentials))
    .build();
    
     TransferManager xfer_mgr = TransferManagerBuilder.standard()
    .withS3Client(s3)
                .withDisableParallelDownloads(false)
                .build();
    
     File f = new File("xxx/image.jpg"); //specify path to your image 
     String objectName = "newimage.jpg"; //provide a name for the image how you want your image to be shown i
     Upload xfer = xfer_mgr.upload(bucketName, objectName, f);   
     xfer.waitForCompletion();  
     xfer_mgr.shutdownNow();
    

For more reference you may check this link

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!