this patch allows advagg to store aggregate files using stream wrappers other than the default "public" wrapper. i developed this in order to use with the amazon s3 file stream wrapper provided by the amazons3 module, and it should work with any properly implemented stream wrapper.
The patch creates a text field in the admin page where you can set the stream wrapper, and then uses the stream wrapper when writing drupal file records. It defines "public" as the default stream wrapper, and will always use "public" unless a different value is set in the admin form.
I also found that drupal's record of MIME types in file_managed were getting lost in certain contexts when temporary files were used, so i made it write temporary files with the same file extension as the original file name, which allows drupal to preserve the MIME type all the way through the process.
Comment | File | Size | Author |
---|---|---|---|
#8 | advagg-mimetype-2143913-8.patch | 824 bytes | aviindub |
stream_wrapper_and_mime_type.patch | 4.72 KB | aviindub | |
Comments
Comment #1
aviindub CreditAttribution: aviindub commentedComment #2
aviindub CreditAttribution: aviindub commentedComment #3
mikeytown2 CreditAttribution: mikeytown2 commentedComment #4
aviindub CreditAttribution: aviindub commentedim seeing some issues after running this patch with the advagg 2.3, so I'm going to work on this a little more and resubmit.
Comment #5
mikeytown2 CreditAttribution: mikeytown2 commentedUsage of hook_advagg_get_root_files_dir_alter($css_paths, $js_paths) is the preferred way to change the css and js paths. I want to keep the admin section as clean as possible so if the alter hook is a no go, creating a "hidden" setting would be ideal. Document the hidden setting in the readme as well.
Comment #6
aviindub CreditAttribution: aviindub commentedthanks, i will make that change and see if i can make it work.
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedAlso noted is
hook_advagg_save_aggregate_alter($files_to_save, $aggregate_settings, $other_parameters)
. This will allow you to modify the full path before saving or even saving the file in 2 locations. I use this hook for saving .gz files and using packer js compression on non gzip files.http://drupalcode.org/project/advagg.git/blob/refs/heads/7.x-2.x:/advagg...
Comment #8
aviindub CreditAttribution: aviindub commentedThanks to your input, i was able to implement the functionality i need via hook_advagg_save_aggregate_alter and hook_advagg_get_root_files_dir_alter. There is only one remaining component that i need to submit a patch for, which is to add the file extension to the temporary file name when saving aggregates in order to preserve the MIME type in the alternate stream wrapper. Patch is attached.
Comment #9
aviindub CreditAttribution: aviindub commentedin case you are curious, here's what my implementation looks like:
Comment #10
mikeytown2 CreditAttribution: mikeytown2 commentedNice work :)
Patch in #8 has been committed.
Comment #11
aviindub CreditAttribution: aviindub commentedThanks!