Both methods you mentioned are valid for uploading files via REST API, but they have different use cases.
1. Base64-encoded string:
This method is useful when you need to include the file content as part of a larger JSON payload, for example when creating a new entity that includes a file attachment. By encoding the file content as a base64 string, you can include it as a field in the JSON payload and avoid the need to send a separate binary file.
2. File upload parameter:
This method is useful when you want to upload a file as a standalone operation, or when you need to upload a large file that may exceed the maximum JSON payload size. By sending the file as a separate binary parameter in the form-data, you can stream the file data directly to the server and avoid the need to buffer the entire file in memory.
For your use case of accepting file types like jpg, jpeg, gif, png, txt, pdf, and docx, you can use either method.