I'm using graphql-upload to upload a file from a web client to an apollo express server to another server, which is expecting a PUT
request with a file for avatarImage.
The file is coming into uploadLogo() correctly. I'm able to save and view it from the express server. When I pass the stream of the file to PUT /avatar, that endpoint doesn't receive it. I've tested sending a file directly to /avatar from the filesystem and can confirm the endpoint is working correctly.
Here is my datasource file where I'm appending the file's createReadStream to the form data and sending that in the fetch put.
class MyAPI extends RESTDataSource {
async uploadLogo(id, file) {
const { createReadStream, filename, mimetype } = await file;
const stream = createReadStream();
const formData = new FormData();
formData.append('avatarImage', stream, {
contentType: mimetype,
filename
});
const headers = formData.getHeaders();
return this.put('http://localhost:5000/avatar', formData, {headers});
}
}
What am I missing to send the stream in the form data to this /avatar endpoint?