Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When Bulk Media Upload is set to use the Image field in a Node which has been configured to upload via the Storage API ( for example to upload images to S3 or Rackspace ) the Bulk Media Upload module still uploads to the Public file system/path.
Comment | File | Size | Author |
---|---|---|---|
#13 | bmu_does_not_respect-1871818-13.patch | 1 KB | botris |
#11 | bulk_media_upload.patch | 1 KB | aznleng |
#7 | respect_schema_of_file_upload-1871818-6.patch | 750 bytes | coreyp_1 |
Comments
Comment #1
michaelpeerman CreditAttribution: michaelpeerman commentedIn my experience i am using Amazon s3 and it is doing what it is supposed to. It reads the files in as a stream to the database then it uploads them to s3 when it is generating the nodes. There are no files left on the server.
What are you using for your integration with s3?
Comment #2
Taxoman CreditAttribution: Taxoman commentedComment #3
coreyp_1 CreditAttribution: coreyp_1 commentedI'm changing the title to better reflect the issue.
The problem is that BMU does not default to the schema of the field on which it operates. Rather, it initializes the upload to the sitewide default for all file uploads, a rather heavy-handed approach, IMO. This is particularly problematic for modules such as Storage API because (for performance reasons) it ignores everything except for its own schemas. For sites requiring scalability, Storage API is invaluable (I wrote the DreamHost DreamObjects integration module, for example). These are the types of sites that will benefit greatly from BMU.
I don't have much time, but will try to help with a patch. If anyone is wanting to jump in, the problem is in the schema selection in the _bulk_media_upload_generate_entity() function, in bulk_media_upload.upload.inc, line 155
Comment #4
coreyp_1 CreditAttribution: coreyp_1 commentedI'm too tired to do a proper patch (in the middle of moving across the country, please have mercy!!!), but here is the change: Replace line 155 of _bulk_media_upload_generate_entity() with these two lines:
before:
after:
In my tests, this fixes the integration issues with Storage API and opens up BMU to support a wider variety of configurations.
For clarity, I will post the entire function below which demonstrates the state of the function after the change has been applied:
Comment #5
jhodgdonI have an image field that is set to store in Drupal's own private file storage, but the files are being uploaded to Public file storage. So this is not just a problem when using external storage.
Comment #6
coreyp_1 CreditAttribution: coreyp_1 commentedTrying to upload a proper patch.
Agreed, it's not just Storage API, but Private file storage as well (which means this could be interpreted as a security issue!).
Comment #7
coreyp_1 CreditAttribution: coreyp_1 commentedComment #8
coreyp_1 CreditAttribution: coreyp_1 commentedComment #9
JemBijoux CreditAttribution: JemBijoux commentedHey folks - I'm no drupal genius, so I can't say much to the efficacy of this patch other than the fact that I just tried it with a site I'm working with, and it fixed up the problem for me (using private file system).
Comment #10
rudolfbykerThe patch solves the problem. Please put in in the next dev version!
Comment #11
aznleng CreditAttribution: aznleng commentedThat patch didn't work for me in #7.
I don't seem to have a field type that has "uri_scheme" in its field instance settings.
I've created this patch that worked in my case. It pretty much checks the allowed_schemes of the file's field instance.
If it contains the default file scheme or if allowed_schemes is not set, it will use the default file scheme.
Otherwise, it will use the first scheme in the allowed schemes array of the file's field instance.
Comment #12
aznleng CreditAttribution: aznleng commentedPatch in #7 did not solve everyone's problem. My patch needs review.
Comment #13
botrisI think the solution can be smaller.
As
field_info_field()
is called later anyway we can just move it up in the function and read the schema value.Tested this with S3 (s3fs) and works fine.
Comment #14
end user CreditAttribution: end user commentedTested #7 and works here using bulk_media_upload-7.x-1.x-dev. I haven't tested 11 and 13 unless for some reason #7 is no good to use