Overview & Techstack
I'm trying to upload images to drive. The server is running Express inside a Docker container behind Nginx.
To authenticate, I'm using Service Account with full permissions to every folder I've tested.
Issue
I receive a perfect 200 status every time. The image that's uploaded is never the actual image. Instead it contains the following redirect html body
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
Tested & Working
I've tested both simple and multipart uploads.
I've also tested uploading to both personal and shared drives
Both of these methods work. The file shows up in the correct folder, just with invalid data.
let fileMetaData = {
name: fileName,
mimeType: fileMimeType,
parents: [folderId]
};
let media = {
mimeType: fileMimeType,
body: fs.createReadStream(filePath)
};
self.driveClient.files.create({
resource: fileMetaData, // required for multipart upload,
media: media,
fields: 'id',
supportsAllDrives: true,
parents: [folderId],
}, function (err, res) {
if (err) {
callback(err.response.data.error);
return;
}
callback(null, res.data.id);
});
Recreation Steps
- Run the code above
- Use any image less than 5Mb
- Receive a '200' OK status on upload and the id of the uploaded image
- Find image in drive (can't open with preview or image viewer)
- Open image with text editor
- Stare at html
Overview & Techstack
I'm trying to upload images to drive. The server is running Express inside a Docker container behind Nginx.
To authenticate, I'm using Service Account with full permissions to every folder I've tested.
Issue
I receive a perfect 200 status every time. The image that's uploaded is never the actual image. Instead it contains the following redirect html body
Tested & Working
I've tested both simple and multipart uploads.
I've also tested uploading to both personal and shared drives
Both of these methods work. The file shows up in the correct folder, just with invalid data.
Recreation Steps