Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure Krakend to support Upload File Endpoint #844

Open
AnandThurubatla opened this issue Feb 13, 2024 · 2 comments
Open

How to configure Krakend to support Upload File Endpoint #844

AnandThurubatla opened this issue Feb 13, 2024 · 2 comments
Labels

Comments

@AnandThurubatla
Copy link

Hello Community Members,

We have been using KrakenD as API Gateway for our Micro-Services. One of our micro-service handles Image upload. We tried in ways to configure KrakenD to support upload Image in Base64 format and binary but no luck. Not found any references too.

Can some one share KrakenD configuration which supports Image upload?

Thanks,
Anand

@alombarte
Copy link
Member

alombarte commented Feb 13, 2024

Hello Anand,

You could start here:

  "endpoint": "/some-file-upload",
  "method": "POST",
  "output_encoding": "no-op",
  "input_headers": ["*"],
  "backend": [
    {
      "url_pattern": "/service/some-file-upload",
      "encoding": "no-op",
      "method": "POST",
      "host": ["http://yourmicorservice"]
    }
  ]
}

Notice the no-op because you don't want KrakenD to encode/decode, and also the input_headers because most microservices rely on specific headers for file upload. Use this until you are certain of which ones you need.

Share logs for further help

@ridgarou
Copy link

Yes, no-op is the solution.

look, this is how I configured one of my endpoints

   {  
      "endpoint": "/v2/profile/upload-image",
      "method": "POST",
      "input_headers": [ "Content-Type", "Authorization", "Accept-Language" ],
      "input_query_strings": [ ],
      "output_encoding": "no-op",
      "backend": [
        {
          "host": [ "{{ .urls.profile.kube_host_url }}" ],
          "url_pattern": "/profile/upload-image",
          "method": "POST",
          "encoding": "no-op",
          "extra_config": { "backend/http": { "return_error_code": true } }
        }
      ], 
      "extra_config": {
        {{ template "jwt_validator.tmpl" .env.user }}
      }
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants