File target fails when the URL (e.g. one provided by an API) redirects to a file, rather than being the direct URL of a file resource

Created on 8 April 2020, almost 5 years ago
Updated 17 October 2024, 4 months ago
  • Some APIs provide resource URLs that do not point directly to a file, but instead redirect the user to the file. For example, https://www.instagram.com/p/B9vy5EdgZX1/media/?size=l is proviuded by the Instagram API, but this actually redirects to https://scontent-lht6-1.cdninstagram.com/v/t51.2885-15/fr/e15/p1080x1080/89738651_155780038891572_5224457300248488192_n.jpg?_nc_ht=scontent-lht6-1.cdninstagram.com&_nc_cat=100&_nc_ohc=rGVubVRCFoAAX8YKjNO&oh=76c6ac182e0432bfffce7539e372631d&oe=5EB77DAB
  • This redirect causes issues for \Drupal\feeds\Feeds\Target\File::getFileName which expects to get a URI that contains a file extension that it can pass to \Drupal\Core\File\FileSystem::basename
  • One fix would be to make a request to $url as part of \Drupal\feeds\Feeds\Target\File::getFileName and update the value of $url whenever a redirect takes place.

Patch incoming :)

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Phil Wolstenholme

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024