asilvas / node-image-steam

A simple, fast, and highly customizable on-the-fly image manipulation web server built atop Node.js
MIT License
169 stars 26 forks source link

301 error message #70

Closed musicformellons closed 5 years ago

musicformellons commented 5 years ago

I have a kubernetes cluster and make a request from another pod for a picture I uploaded to an S3 bucket:

  # curl http://steam-app-server:8888/test.jpeg

And get following output:

  # npm start

      > image-steam@0.48.2 start /src
      > node ./scripts/server.js --isConfig ./scripts/dev.js

(node:29332) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
  Server running at http://localhost:8888
WARN: 2019-02-12T13:38:26.922Z
Error: storage.s3.fetch.error: 301 for myS3testbucket/isteam/test.jpeg/4139548100
         at IncomingMessage.<anonymous> (/src/node_modules/image-steam-s3/lib/index.js:101:28)
         at IncomingMessage.emit (events.js:187:15)
         at endReadableNT (_stream_readable.js:1094:12)
         at process._tickCallback (internal/process/next_tick.js:63:19)
WARN: 2019-02-12T13:38:27.299Z
Error: storage.s3.fetch.error: 301 for myS3testbucket/isteam/test.jpeg/4256729200
         at IncomingMessage.<anonymous> (/src/node_modules/image-steam-s3/lib/index.js:101:28)
         at IncomingMessage.emit (events.js:187:15)
         at endReadableNT (_stream_readable.js:1094:12)
         at process._tickCallback (internal/process/next_tick.js:63:19)
WARN: 2019-02-12T13:38:27.687Z
Error: storage.s3.fetch.error: 301 for myS3testbucket/test.jpeg
         at IncomingMessage.<anonymous> (/src/node_modules/image-steam-s3/lib/index.js:101:28)
         at IncomingMessage.emit (events.js:187:15)
         at endReadableNT (_stream_readable.js:1094:12)
         at process._tickCallback (internal/process/next_tick.js:63:19)
ERR: 2019-02-12T13:38:27.689Z GET /test.jpeg
Error: storage.s3.fetch.error: 301 for myS3testbucket/test.jpeg
         at IncomingMessage.<anonymous> (/src/node_modules/image-steam-s3/lib/index.js:101:28)
         at IncomingMessage.emit (events.js:187:15)
         at endReadableNT (_stream_readable.js:1094:12)
         at process._tickCallback (internal/process/next_tick.js:63:19)

My dev.js:

var path = require('path')

module.exports = {
  http: [
    {port: 8888}
  ],
  log: {
    warnings: true
  },
  storage: {
    defaults: {
      driverPath: path.resolve(__dirname, '/src/node_modules/image-steam-s3/index.js'),
      endpoint: 's3.amazonaws.com',
      bucket: 'myS3testbucket',
      accessKey: 'myS3Key',
      secretKey: 'mySecretS3Key'
    }
  },
  log: {
    warnings: true
  }
}

My questions:

  1. Why do I get 301's ?
  2. Why do I get multiple 'responses' for one request?
asilvas commented 5 years ago
  1. You're getting redirect's from AWS S3 because of bad options. I suspect you need to update style to "virtualHosted". Check out S3 options: https://github.com/asilvas/image-steam-s3#options
  2. Yeah there should only be 2 warnings. Possible bug in the S3 client around error handling. PR's welcome!
musicformellons commented 5 years ago

2 is solved: I had twice logs in my options, after getting rid of these it's ok.

After adding virtualHosted I now get a 400 error:

Server running at http://localhost:8888
ERR: 2019-02-12T16:51:59.666Z GET /test.jpeg/:/rs=w:640
Error: storage.s3.fetch.error: 400 for myS3testbucket/test.jpeg
    at IncomingMessage.<anonymous> (/src/node_modules/image-steam-s3/lib/index.js:101:28)
    at IncomingMessage.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

When I select the test.jpeg in S3 it gives the path https://s3.eu-west-3.amazonaws.com/myS3testbucket/test.jpeg, so the problem might be I am using http instead of https?

asilvas commented 5 years ago

It uses the Knox client, so I'd suggest checking out their docs: https://github.com/Automattic/knox

We don't use AWS S3.