Skip to content

Uploaded Images contain HTML data #2844

@dsingh80

Description

@dsingh80

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

  1. Run the code above
  2. Use any image less than 5Mb
  3. Receive a '200' OK status on upload and the id of the uploaded image
  4. Find image in drive (can't open with preview or image viewer)
  5. Open image with text editor
  6. Stare at html

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions