I ended up with this:
$uri = preg_replace("~\/(?!.*\/)~", DIRECTORY_SEPARATOR, $uri);
/* @var \Drupal\file\FileInterface $files */
$files = \Drupal::entityTypeManager()
->loadByProperties(['uri' => $uri]);
but pretty sure this is a bug in core.
From your Dashboard, navigate to Appearance » Widgets. Then, under Available Widgets, click on the YouTube Feed widget. Choose which area you'd like to display it on, and click on Add Widget to save your choice. After doing this, check out your website and see your channel feed nicely displayed on your sidebar.
Take a look at foldershare and foldershare_rest modules, they provide entire data management pipeline on a Drupal site, along with a ready to use rest client cum command line utility. Here are couple videos that show the module's capabilities
Managing data via REST client for automation and power users (5 mins)
Managing data on SeedMeLab for users(3mins)
I just made a solution that works for me even the Drupal or config doesn't works properly. In my plugin I hooked up the hook_cron() for logging these unused files to proceed them next.
SQL SELECT; query to fetch all file_managed fid's. You can select only status=1, as permanent files, but I got all,
PHP loop all id's and making a Drupal\file\FileInterface ...
Piggybacking on Tien Wang's answer, here is an example using a file entity:
$headers = array(
'Content-Type' => $file->getMimeType(),
'Content-Disposition' => 'attachment;filename="'.$file->getFilename().'"',
'Content-Length' => $file->getSize(),
'Content-Description' => ' File Transfer'
return new ...
I wrote this module to solve this problem in a generic way. https://www.drupal.org/project/anonymoussession
use this code before using the session, and you application works for both known and unknown visitors.
$anonymousSession = \Drupal::service('anonymoussession');
The specified file temporary://filel17IDM could not be copied, because the destination directory is not properly configured.
The problem is with the destination directory, not the temporary directory (which defaults to /tmp on Linux systems).
/tmp typically looks like this:
ls -la /tmp
drwxrwxrwt 13 root root 4096 Feb 19 09:52 .
Which means that any user ...
I needed to do this in Drupal 8. And then did it the same like I found it in file_preprocess_file_link in core. Doing it like that makes it agnostic, no matter if public or private file. You get the link.
$mime_type = $file->getMimeType();
$file_size = $file->getSize();
$file_name = $file->...
I figure out what the problem was. I'm posting the solution for my case just in case someone has the same problem.
My problem was that I had change the submit button ID in the input.html.twig file. I replaced it to the original and it works fine.
I am using Drupal 9, in my case the folder where the translations are saved was missing. When I went to "Home -> Administration -> Configuration -> Multimedia", the path of the translations was in "sites / default / files / translations" and I was missing the "translations" folder.
You can upload images and create media without the File Entity module and any module fixes.
New "file_upload" REST resource plugin: allows file uploads of any size, creates File entities
In your case, the request would be like this:
POST /file/upload/media/image/field_media_image?_format=hal_json HTTP/1.1
You can achieve that by adopting the below snippet to your use case.