how to duplicate a file field entry from drupal commerce to another field so it can be previewed - file

Im looking for a way to copy a file being uploaded to drupal commerce using commerce file/license to another file field in drupal 7. I want to preview audio files being sold on drupal commerce but because of the private file structure that is forced by commerce license, I have to duplicate the file to another field that is public.
Is there a way to copy a file being uploaded to a public directory and also add a database entry for an additional field associated to the content type?

Basically you have to create a "public mirror" of the file you uploaded.
Not digging to much in code, since commerce_product is an entity we assume we can alter the product whenever it is saved, so you can to as follow:
create a module and use hook_entity_insert and/or hook_entity_update
find the file you need, make a public copy
fill the value of the public file in another field of the same entity

Related

Logic Apps SharePoint Connector - When a file is created or modified in a folder

I have an integration scenario where I need to pull documents from SharePoint Online and submit the content (PDF) to a downstream API. I'm using the When a file is created or modified in a folder trigger to pull documents from a SharePoint library. My question is whether there is a way to set a filter on the trigger so that only PDF documents are retrieved i.e. (*.pdf)?
For this requirement, you can click "Settings" of your trigger.
And then add the expression #contains(triggerBody()?['{FilenameWithExtension}'], '.pdf') to "Trigger Conditions".
After that, the logic app can just be triggered with file name which contains .pdf.
=================================Upate==============================
You can change the expression to:
#contains(trigger().outputs?['headers']?['x-ms-file-name'], '.pdf')

cakephp - How to authorize assets?

In a CakePHP3 application that requires Authentication/Authorization, I have the possibility of images being uploaded. Now I would like to avoid Users being able to see other users images by e.g. guessing image names or such. Also I would like to use the ids of the entities as filenames which would make it also easy to guess.
So how would you implement authorization for assets?
I would prevent the "guessing" of filenames just by generating a random long enough unguessable string of chars as the new filename, like Facebook does with uploading photos:
Because we shouldn't bother at all with the original name of files, we could rename the file that a user uploads. For example User 24976 uploads a file that is called tomato12.png. The upload script will then rename the file to (for example) the following name:
1481540475_24976_iDewM51NYrBYgnIh.png
It consists out of four parts:
[timestamp]_[userId]_[randomString].[suffix]
And then, save the filename into the database. If you would look into the uploads directory, you could be able to see which user has uploaded which file, but an outsider that has no rights to see the directory index would never be able to guess the name of a file. No authentication needed.

Automatically Creating Pages on the Server When an Entry in a Database is Created

Using PHP, does anyone know how to make it so that when someone registers on a website (and therefore enters data into a database), a folder with a default php file is created on the web root/server???
This is not a good design. Rather, you should have your PHP files look at the session to find the logged in user's id, and query the necessary data about that user id. You don't need a file for each user. You can make your table auto-increment a user id.

Restricting uploads in the DotNetNuke Text Editor using the "add link"

I am building a DotNetNuke 5.6 Module. The module contains a form with some textboxes and the dotNetNuke Rich text Editor.
Users are supposed to fill this form and it is saved to the database.
Everything is working just fine.
The problem though is that users can use it to upload images or documents to the server if they select to add a link.
The problem here is : Users will upload documents to the portal root which will make them visible to other users. We do not want this to happen as each user's documents are private and should not be visible by other users.
The question is:
Can I restrict users to upload documents to a specific folder visible only to that user? this is to prevent different users from seeing each other's private documents?
OR
Can I restrict users from uploading documents altogether?
Thanks
Folder security settings are found in the Admin - File manager. Write permissions control upload:
Allowable File Extensions are in the Host Settings - Other Settings. This is a global security feature, and does not include common media file extensions by default:
In addition, different HtmlEditorProviders do have folder and upload settings in their configuration. HtmlEditorProviders are configured with provider-specific web.config properties and configuration files that are found under /Providers/HtmlEditorProviders.
Telerik provider has ImageManager.ViewPaths, ImageManager.UploadPaths and ImageManager.DeletePaths properties, and also maximum upload sizes for different file extension groups (image, media, document, flash, silverlight, template ). Cute Editor has some support for role-based default upload directories, but I couldn't find these in the Telerik provider.
See also:
How to Upload Restricted File Types in DotNetNuke

Attached files rights for Drupal

on my website i have two types of files that end users can download - one of them are available for all visitors, and second is only for registered users (users that are logged in).
setting of drupal allows to set only if files are available for all users or only for users that are logged in.
how can i achieve that some files are public and some not?
thank you in advance!
Assumption: you're using Drupal 6.
If you're using the upload module to attach files to your nodes: consider using http://drupal.org/project/private_upload
If you don't mind creating manual links to the files in your Node bodies (and uploading the files yourself to the private folder) consider http://drupal.org/project/private_download
If you're using filefields consider using http://drupal.org/project/filefield_private
Some up these modules have hardly an uptake (click on the usage statistics link on each of the above links I've shared with you).
Unfortunately mixing private and public downloads is a known area of weakness for Drupal 6. Drupal 7 has fixed this.

Resources