suntrop Posted January 4, 2018 Share Posted January 4, 2018 I need for an web app files that keep their original names. Like “A new flavour from Häagen-Dazs.pdf”. Why? Because my web app is some kind of file sharing (for a company) and those files need to be re-integrated into their original place. The company uses a DMS that partly relies on file names. If they get back “a-new-flavour-from-hagen-dazs.pdf” it’ll break consistency. I tried but couldn’t get rid of the file name validation. Is it possible to disabled it? I couldn’t find a hook for file uploads. Is it possible to hook into it and change back the original name? ... or instead, save the original name in the file description? So when I download the file I can pass in the original name? Another ugly way would be to just store file paths in a multiplier or just a folder path (but that excludes admin users uploading files within PW) I read a blog post by soma with an interesting solution to store files as a dedicated page. This would come in handy, because I need to manage access on all files anyway. Most files are coming from and front end upload form. But the admins will work on the PW backend and that is quite combersome to create for every file a new page, name it accordingly, upload the file and create a reference. On github I found a workaround by @matjazp but the Dropbox link isn’t working anymore. https://github.com/processwire/processwire-requests/issues/56#issuecomment-263669255 Link to comment Share on other sites More sharing options...
dragan Posted January 4, 2018 Share Posted January 4, 2018 Never tried something like this. In fact, I'm glad PW has this feature... I would try with 3) - take a look at this hookable method: https://github.com/processwire/processwire/blob/master/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module#L532 Link to comment Share on other sites More sharing options...
kongondo Posted January 4, 2018 Share Posted January 4, 2018 Although it has worked for some, personally, I wouldn't bother with hooking into file uploads or storing original names in the file description or #4. I would either go for 'one-page-per-file' approach or create a custom Fieldtype that extends FieldtypeFile. 1. Page approach Besides the advantages you've alluded to, other advantages are: You file 'gets a unique ID'. Normally, files/images do not have IDs. For a critical system like yours, you might find an ID useful, e.g. to easily locate files Extensible: Using a page, you can add fields to it if such a requirement arises in the future. Easy to edit files Edit a file in one place, have the changes applied everywhere you are using it Etc... Now, this does look familiar... . Media Manager uses the same approach. It is just a bit more refined. The pages containing media are hidden, are auto-created and users do no interact with them directly. Shameless plug; if all else fails; consider buying MM . I know one developer who used it to manage PDF files for an organisation. 2. Custom field The task at hand is a good opportunity for a custom Fieldtype. Create a module that extends Fieldtypefile. Copy the code in Fieldtypefile, adjusting the schema to accept an additional text column/field (for the database) where you can save your original file name. We can help you with this 3. Profields Table? 2 Link to comment Share on other sites More sharing options...
matjazp Posted January 4, 2018 Share Posted January 4, 2018 I updated the links to the files in my dropbox... Link to comment Share on other sites More sharing options...
kongondo Posted January 5, 2018 Share Posted January 5, 2018 Something like this? (Exended FieldtypeFile) 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now