Firstly, thanks for a great module!

I have a case where I would like for the file path stored location inside my files directory [sites/default/files] to be different then the url alias the user will see.

Expected behavior I would have liked was for the URL the users see when the file is served to them sitedomain.com/category/filename.pdf and the actual file is stored at sitedomain.com/sites/default/files/pdf/category/filename.pdf. However when setting these in the file field path settings I'm getting the drupal error "The requested page .. could not be found."

If I set the file path and file alias settings to both include the pdf/ in the beginning of the path like the following then the file gets served as expected.
File Path: pdf/[node:field-category:url:relative].
File Alias: pdf/[node:field-category:url:relative]/[file:ffp-name-only-original].[file:ffp-extension-original]
Then the file gets served as expected at sitedomain.com/pdf/category/filename.pdf

The module seems to only take care of allowing one to create an alias that the user won't see the sites/default/files/ directory structure in the url path but any other folder paths created inside that directory needs to be displayed in the alias as well. Is there a way we can set that to not be the case?

Steps to reproduce issue:
- install the following modules file_aliases, filefield_paths, token and any dependent modules
- create a term vocabulary called "pdfs" with two terms
- create CT with a category term reference type field to reference the above created vocabulary terms in this content type with the select option
- add a file upload field
- set the file path settings in the file field settings to pdf/[node:field-category:url:relative] (insert correct 'field-category' token for the category field that was created above)
- set the path alias settings to [node:field-category:url:relative]/[file:ffp-name-only-original].[file:ffp-extension-original]
- create a piece of content in that content type and upload a pdf file
- choose a term/category from the category field
- once viewing the node with the file displayed on it try to open the file
- I get the standard drupal error "The requested page .. could not be found."

CommentFileSizeAuthor
file-field-settings-screenshot.png136.54 KBhershey.k
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hershy.k created an issue. See original summary.

hershey.k’s picture

Title: File Alias only working when matching File Path » File Alias only works when matches exact File Path directory structure
hershey.k’s picture

Issue summary: View changes
hershey.k’s picture

Issue summary: View changes

Clarifying issue.

hershey.k’s picture

Issue summary: View changes
hershey.k’s picture

Component: User interface » Code

  • Deciphered committed a0ca5ed on
    #2620140: Fixed issue with rooted and URL based URL aliases.
    
Deciphered’s picture

Status: Active » Needs work

Is fixed and committed... although tests are failing on Drupal.org, so possibly still needs work.

The issue was/is that the token you where using was putting a forward slash at the from of the alias (it was a relative URL after all) where the Path Alias system doesn't work with a forward slash at the starts (even though it lets you have it). The solution is simply to cleanup the alias after it's processed, which is done and committed.