Questions tagged [files]

Use it to generally reference to those files used on websites which could be video, images, pdfs, etc.

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views
+50

Link to images in form view creates wrong url

I noticed this after drupal 9 update, but I've tried to find the exact moment when it was broken and I couldn't find it. I use S3 and cloudfront for images so maybe the problem is related with that ...
-1
votes
0answers
36 views

How do I get the path of temporary directory in procedural contect?

On a site running 9.3.3, I need to get the path of the temp directory. There is a public function for that: getTempDirectory(). The following code works fine in an OO context using DI: use Drupal\Core\...
0
votes
0answers
22 views

Image compression problem

I keep on running into an issue with image compression on Drupal. I have a set of good quality, clear images, that I'm resizing down to 100px by 100px in CSS. When I resize, the quality worsens and ...
-2
votes
0answers
16 views

What is the url of the entity linked to a FieldItemListInterface

I am checking the code of this field-formatter-plugin especially the function that format the output of a view: /** * {@inheritdoc} */ public function viewElements(FieldItemListInterface $...
0
votes
1answer
22 views

How to compare the original file and replacing file to upload prior to the action of physical uploading?

I would need to know if the new file that is about to be uploaded has the same URI function hook_validate($form, FormStateInterface $formState) { //code to get the replacementFile name before file ...
1
vote
1answer
34 views

How to migrate files from outside Drupal, with files already where they need to be, creating file entities

I'm doing a migration from a non-Drupal site--so far, for test purposes. I have all the data in CSV files. Since I'm brand new to migrating into Drupal 9 from outside Drupal, I'm learning this in ...
1
vote
0answers
20 views

Restrict a Media field to allow selecting only a certain file extension in an existing Media Type

Is there a way to restrict a Media field using an existing Media Type (File) in a Content Type to permit only a certain file extension in that instance? In particular, I need a subset of the permitted ...
0
votes
0answers
16 views

How to set an encrypted file field's value programmatically

I'm trying to set an encrypted file field's value programmatically. I'm using Encrypted Files module. I have successfully configured a file field, and it works for the contents created using the node ...
1
vote
1answer
39 views

Is it possible to allow anonymous users to view a temporary managed file via hook_file_download()?

I am creating a live image preview system for customizable products that needs to send a user's temporary file to a remote server. I have a token-based system to protect the file but the problem seems ...
1
vote
0answers
49 views

Why are the images referenced using a relative path instead of an absolute path?

I have installed my Drupal site on my localhost under a path like /websites/mysite/drupal. Most files get loaded correctly, such as those at /websites/mysite/drupal/sites/default/files. For some ...
2
votes
1answer
31 views

get the file URI of an ImageItem

How can I get the file URI of a Drupal\image\Plugin\Field\FieldType\ImageItem instance? I get the field value with $node_entity->get('field_image')[0] but I don't know how to get the file URI.
1
vote
1answer
18 views

Reference private file?

I'm making migration plugin which I'm using in first migration and it is creating private file like this: if ($final_destination) { // Create a file entity. $file = File::create([ 'uri' => $...
0
votes
1answer
24 views

Creating file from s3fs (S3 bucket) breaks migration

I have s3fs module installed and configured, so when I upload some file it goes to S3 bucket. Then I'm making processing plugin which should copy file from another S3 bucket to Drupal's bucket and ...
0
votes
1answer
16 views

How to make the private image accessible with image style?

I have a private image with this URL. http://mystite.com/system/files/images/IMG_0371_24.jpg/IMG_0371_24.jpg An image style is created for the above image on location http://mysite.com/system/files/...
0
votes
1answer
32 views

Unable to upload files through RESTful services

I am trying to upload pdf files to webform submission using REST API. Since the Core File Upload functionality did not seem applicable for webform submission, I applied the patch from webform_rest ...
0
votes
0answers
25 views

Getting 403 randomly on files

I have a react-native app that authenticates with Drupal via oAuth2 (simple_oauth, openidconnect) and do not use cookies. I use my access token for all rest calls, images and other files. Very ...
0
votes
1answer
38 views

How to edit file 'description' label and help text

I want to edit the file upload description label and the help sentence underneath it: I tried the below code: function mymodule_field_widget_form_alter(&$element, FormStateInterface &$...
0
votes
2answers
27 views

redirect an old url that no longer exists related to a file to a new one

I have 2 urls: www.example.com/somefile.pdf www.example.com/somefileNew.pdf the first one no longer exists, i want to redirect this url to the new one. I tried to use the redirect module to no avail ...
0
votes
0answers
25 views

How can we directly display/download attached document on Media path

I am trying to directly display/download the attached file when the Media link is reached. Main reason behind this is to avoid providing file path directly. For example: if a user is visiting www....
1
vote
1answer
73 views

Add custom font to mpdf while using PDF using mPDF module

I made a custom module to create a PDF from a views page. This module depends on PDF using mPDF. I'm now trying to add a custom Google font. This should be the default font when generating a pdf. But ...
0
votes
1answer
39 views

How can the custom files copied by code to the private directory be accessible through URL for authenticated users?

In my project, I am using headless Drupal with .Net on the front end. I have to use private and encrypted file systems for the project requirements. The files which I am uploading through Drupal ...
0
votes
2answers
55 views

How can i render a file using a formatter programmatically in a controller?

I'm trying to create a controller to render a swagger documentation using the module swagger_ui_formatter that provide a formatter to the file field that render swagger files (yml, yaml, json) using ...
1
vote
0answers
38 views

Files migration from local dev site

I'm migrating from Drupal 7 to Drupal 9 and am having an issue with my source files getting found with the upgrade_d7_file migration. My public files directory for my source site is not 'sites/default/...
0
votes
0answers
20 views

Getting different Public path for admin and anonymous users

My site was built using Lightning Drupal distribution. I had my public path as /sites/default/files. I did change the configuration path to /sites/<my_domain>/files in the middle of the project. ...
0
votes
1answer
36 views

Ckeditor inline images path

I am running a Drupal 9 site and I expect my users to upload a lot of files with the ckeditor functionality. All of those files will be stored in a single folder. I heard that this will cause ...
2
votes
0answers
40 views

S3FS IMCE File upload issue for old files in Upgraded site

I have a question on IMCE File upload. Hope someone might have come across the similar issue. Installed modules: https://www.drupal.org/project/s3fs https://www.drupal.org/project/imce We have added ...
-1
votes
1answer
28 views

Downloading xlsm is disabled for anonymous user: What function is responsible for this access control?

We have a D7.8 site with Panopoly 7.x-1.81. No access control modules. A standard filefield is used for uploads and functions perfectly for the usual set of mime types. We recently extended the list ...
0
votes
0answers
80 views

How to programmatically grant access to private files?

I was working under the idea that i could use hook_file_download to grant access to private files; but it seems that this hook can only be used to restrict access to files, not to grant access. I have ...
1
vote
1answer
36 views

How can I delete a file served by a custom controller after it has been downloaded?

Starting from How do I create a file download URL? I've build a custom controller that allows users to download a PDF file. my_module.routing.yml my_module.pdf_link: path: '/my-module/pdf/download' ...
0
votes
1answer
51 views

How do you set the file extension while uploading images through file_save_data?

I am trying to create a product with a product image on drupal using API. I have created a custom module for the same under which following code to upload my image to the Drupal: $path = base64_decode(...
0
votes
0answers
19 views

Image is not showing on the product edit page after creating the product using API

I am trying to create a product with a product image on drupal using API. There was nothing given regarding uploading an image in API so I created a custom module under which i used this code to ...
1
vote
0answers
35 views

How are compiled CSS and JavaScript files handled with S3?

I have my Drupal site set up to upload public files into the S3 bucket but am having some strange behavior with different environments and different s3 buckets. I have 3 s3 buckets: one for our ...
0
votes
0answers
16 views

Managed file element in custom field module doesn't save target id

I have been breaking my head on this issue for a few days now. Using Drupal 9.2.x, I am building a custom field module for a client that has multiple fields. I isolated the problem by only including a ...
0
votes
0answers
46 views

Is it possible to generate a link to a private file that can be shared with an anonymous user to download the file?

In Drupal 8 we need to generate a link to a private file that can be shared with an anonymous user to access. In our function we have the file object for the private file and are currently generating ...
0
votes
1answer
15 views

Front and backend public files not found [closed]

I'm trying to display some image in my front and my backend, a simple image, not a media, but I'm always receiving a 404. For example, I'm trying to display the icon from my paragraph, to i'm ...
1
vote
2answers
40 views

?_format=json does not produce JSON for files, REST

I am using Drupal 9.3 with REST UI, RESTful Web Services, and Serialization enabled. For the REST UI, I have the following configuration for files: Methods: GET, POST, DELETE, PATCH Accepted request ...
0
votes
0answers
43 views

Why can't admin access private file?

I have a file field as part of a Paragraph. The Paragraph is attached to a node bundle. Each paragraph can hold a single file. I have added the same file to the node (each in its own paragraph) ...
-1
votes
1answer
39 views

Download Single Webform Submission CSV

I would like to download the webform submissions one by one. Currently the core of Webform owns to download all submission data to a CSV. Webform -> Result -> Download How to download one ...
0
votes
0answers
34 views

How can I change the "sites/default" into "web/sites/subsite" on the new location?

I have moved the content (files and database) of my "traditional" site (no composer, single site, using sites/default/files folder ) to a subsite on a multi-site that is created using ...
0
votes
0answers
23 views

How to get the file destination from a content type's field_image to upload programatically

I have a cron job that goes and grabs content from another resource and uploads it into my drupal site, and this includes a link an image that I retrieve and upload into my S3 file system. My site's ...
0
votes
0answers
84 views

How to decode base64 image using pre save hook?

I am uploading image using jsonapi. But here the data is base64 format (As per requirement). Uploading to media entity. So I need to write a hook media entity pre save so that file uploaded should be ...
1
vote
0answers
103 views

How can I have the file upload destination private by default?

Currently Webform file component uses public files as default upload destination. This is probably because private files path is not always available if not configured in Drupal settings correctly. ...
1
vote
0answers
78 views

How to programmatically update a file uri in a node

I'm programmatically moving a pdf file and then trying to update the uri in the node. Here's my code: $node = \Drupal\node\Entity\Node::load($nid); $entity = $node->field_pdf->entity; if ($...
0
votes
1answer
59 views

How to send dynamic content as an attachment file in email?

Normally we send files as attachments in the email if they are stored in the file system. $file->uri = 'sites/default/files/file_name.pdf'; // File path $file->filename = 'file_name.pdf'; //File ...
-1
votes
2answers
460 views

Change system file temporary maximum age

The default setting given to delete temp files is after 6 hours minimum. I have users upload files and I want that if it has temp status, delete it after 15 secs. Tweaking the file module code is ...
0
votes
0answers
43 views

How can I assign multiple files to the same field in a migration lookup?

In a first migration step, I import files. Therefore, I read a csv file, containing filenames and attributes about the files. Files can share the same attribute like so: file,attribute,... ex1.pdf,666,...
1
vote
1answer
102 views

How can I upload and read an unmanaged file?

On a custom form I have a file field. Having chosen the file and clicked Submit, I'm trying to find how to access and read the uploaded file. I have no need to move or save it, I simply need to open ...
0
votes
0answers
175 views

How to work around check for `sites/default/files` during Drupal installation, if you're not planning on using it?

I'm working with a server where I don't have shell access and I've dropped the database in an attempt to reinstall Drupal (having run into issues with a failed deployment). When I try to step through ...
0
votes
0answers
45 views

After the update 8.7.14 to 8.8, the File module causes error when uploading a file

After updating Drupal 8.7.14 to 8.8, I have a problem with the File module: When I upload a file, I get the This value cannot be zero error message. The file is however present in the site/default/...
2
votes
0answers
49 views

Theming a file link by adding custom file name suggestions

I want to display a bunch of data inside a view table, where each dataset has up to three different files. The user should be able to download these files by clicking a custom button or image in this ...

1
2 3 4 5
49