Binary Response Simulation (Custom File Uploads)
Beeceptor's custom file upload feature serves as an effective tool for testing, allowing you to simulate large API or HTTP responses, transmit binary content, and evaluate gz compression in HTTP or API responses. This documentation provides insight into various practical applications for this feature.
This feature is available with paid plans.
Configuring Binary Response
To configure a binary response in Beeceptor, follow these steps:
- Open the mocking rules dialog for a specific endpoint.
- Click on "Create Rule".
- Set up the request's matching scenarios.
- In the response section, select 'Send a file/blob' as illustrated in the following demo.
- Choose and upload a file.
- Save the rule.
Once this setup is complete, accessing the API endpoint will result in streaming the file's content as a response. The HTTP response will adhere to the Content-Type and HTTP Status Code specified in the rule configuration.
Use Cases
This feature is versatile and can be applied to a variety of test scenarios. Here's a list of potential use-cases that you should consider:
- Large Payload Testing: Simulating large API responses from a 3rd party service to test the performance and stability of your applications.
- Binary Data Handling: Testing how the applications handle binary data, such as images or PDFs, by streaming them back in API responses.
- Content-Type Validation: Ensuring client applications correctly handle various content types (MIME types), especially when the content type is not accurately detected and requires manual setup.
- Compression Techniques Evaluation: Assessing the efficiency of gzip compression in API responses, particularly relevant for optimizing performance in network-constrained environments.
- Download Functionality Testing: Verifying the download functionality in applications by using the
Content-Disposition
header to prompt file downloads. - Rest API With Blob/File Response: Assessing the client's handling of binary responses from REST APIs is when media uploads and downloads are involved. This testing is critical for maintaining the integrity of media transfer functionalities.
- Error Handling for Large Responses: Evaluating the robustness of client applications in handling errors or timeouts when dealing with large API responses.
- Mime Type Checks: Testing how applications process different file content-types and mismatched content-types by simulating responses with varied mime types.
- Security Testing (Content Sniffing): Assessing the security of HTTP client applications by uploading files with potentially malicious content to see how the system handles them.
Important Considerations
- You can upload files with a maximum size of 10MB.
- Beeceptor tries to auto-detect the file's mime type (content-type). If it fails to do so accurately, manual specification of the content-type is recommended for optimal response behavior.
- Using the Content-Disposition Header: For binary file formats, if you intend for the file to be downloaded under a specific name, add the Content-Disposition header. For example:
Content-Disposition: attachment; filename="your-filename.jpg"
- Current Limitations:
- Enhancement for file uploads for Rule Management API is in progress and will be released in the near future.
- File uploads are not yet available for weighted responses. To request this feature, please contact Beeceptor's support team.
- Files that are uploaded but not used or referenced in any mock rules, will be automatically deleted after a 30-day period of inactivity.