0

How do I create a route that opens an external file?

As an example I have an XML file in my S3 bucket. I need to create a route to open that file from my website.

Is there a way to achieve this without calling a controller? Can I just set a property in the .routing.yml file for this?

my_module.index:
path: '/file.xml'
defaults:
  _controller: 'Drupal\my_module\Controller\moduleController::view'
  _title: 'file View'
requirements:
  _permission: 'access content'
0

Is there a way to achieve this without calling a controller from the route file?

No, a route needs a controller, no exceptions. If you can find an existing controller/method that does what you need, reliably, then you should use that. If not, you'll need your own controller and method.

3
  • It says Unable to parse the controller name "FrameworkBundle:Redirect:urlRedirect". The document you have mentioned is for symfony. How do I use FrameworkBundle in Drupal – i am batman Jan 30 '18 at 11:25
  • Oh right, that's for bundles. Answer updated – Clive Jan 30 '18 at 11:48
  • You can also make a controller and do a TrustedUrlRedirect, but I don’t know how many files we are talking so it may not be a scalable solution. – Kevin Jan 30 '18 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.