- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Uploading file to S3 using Rest Assured multipart.
We can upload files to S3 using Rest Assured multipart with the help of the below techniques −
Rest Assured has the default URL encoding feature. The issue with S3 URLs is that they contain special characters such as %2A, %3D. As the URL encoding feature is configured to true value by default in Rest Assured, we are required to set it to false so that the special characters are not transformed to ASCII equivalent value during runtime.
Rest Assured appends a default charset to the content. This causes a problem if the content type is not given. In some scenarios, we might be required to mention the content type in the header. Simultaneously, Rest Assured appends the default charset to the content type while sending a request. This causes unexpected behavior. To get rid of this, we need to set a false value to the class EncoderConfig.
Sample Code Implementation
given(). //setting urlEncoding to false urlEncodingEnabled(false). //upload file is of JSON type header("Content-type", "application/json"). //setting class EncoderConfig to false config(RestAssured.config().encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false))). body(Files.readAllBytes(Paths.get(payLoad.json))). when(). put("endpoint"). then(). log().all().and() .assertThat().statusCode(200);
- Related Articles
- Splitting and uploading extremely large files to Amazon S3
- What is Rest Assured?
- How to parameterize tests with multiple data sets using Rest Assured?
- How to verify a JSON response body using Assertions in Rest Assured?
- How to get JSON fields(nodes) based on conditions using Rest Assured?
- Validate JSON Schema in Rest Assured.
- Explain DELETE request in Rest Assured.
- What is XmlPath in Rest Assured?
- Explain PUT request in Rest Assured.
- How to handle static JSON in Rest Assured?
- How to validate XML response in Rest Assured?
- How to get a JSON field in a nested JSON using Rest Assured?
- How to iterate through and access the JSON array elements using Rest Assured?
- How to pass the request body from an external file in a separate package in Rest Assured?
- How to use the then method in Rest Assured?