my goal is to massupload images with tags (media & mediabrowser_plus) and sell them with commerce file

since commerce file creates its own file_field instances instead of using existing multimedia_asset_fields i settled for a workaround approach using feeds.

here is my proof of concept in case someone wants to have a look.

http://fserver.rack.rosenstrauch.com/node/1

i would prefer to make commerce file use existing media asset fields though ... please tell me what you think!

Comments

michob’s picture

I'm looking at doing a similar thing with video... I'm wondering what the workflow is for the user in your case - do they have to upload the files first and manually select them to be "commercialized" or is the process automatic for each file? I'm hoping for the latter for my application but from everything I've read so far, it seems like using the Feeds method is manual (or via a cron job).

thanks!

discipolo’s picture

yep, its almost automatic - he has to import the uploaded mediafiles using feeds (could be automatized)

discipolo’s picture

StatusFileSize
new2.55 KB

i also tried to extend commerce_file to let me pick existing producttypes with media asset fields.

i havent really gotten beyond the settings form though. its only a little stub using code from the exif module.

discipolo’s picture

Title: Selling Images using Media » allowing commerce_file to use existing media assets
Component: Miscellaneous » Code
Category: support » feature
StatusFileSize
new8.72 KB

hijacking this feature since i would prefer this approach.

i added a widget to the patch (includes previous changes, against current git) i still need some help getting the fid and writing it into the field.

discipolo’s picture

StatusFileSize
new9.36 KB

who would have thought, i got it working. probably have to clean it up a lot though (locale or defaults for instance) but as a proof of concept this should be a starting point

recrit’s picture

Media field will not be supported until it can provide a private file scheme that is needed to sell files. - @see http://drupal.org/node/1069582. The Drupal core file field has this support natively which is why Commerce File Field is a wrapper around that.

@discipolo: Your patch changes a lot more than just add media support - remove licensing settings, overrides options widget field types with solely media, etc.

Alternatives:
The filefield_sources module provides an easy way to reference existing files (http://drupal.org/project/filefield_sources); however, it is currently limited to only referencing files associated with the field, ie not all files on the system. Also it would need to take into account the allowed file schemes.

discipolo’s picture

aha, i see
mediafiles get saved to the right location, even using the field upload. but there is something wrong with the displaylinks. will investigate further.

recrit’s picture

I did some testing and have figured out how @discipolo could have had the files being stored correctly in the private file system.
The media module uses the following for the file scheme instead of the 'allowed_schemes' defined in the field settings. Also line 253 of media.fields.inc states "// @todo: Not implemented" above the allowed_schemes setting.

$scheme = variable_get('file_default_scheme', 'public') . '://';

Since it uses the default, the only way to have media module store a file in the private file system is to set the default for the entire site to be "private". This is not ideal for performance reasons. The best case is to have a public default and then only the file you want private to be in the private file system.... thats the power of the new D7 file system.

To sum it up, the media module still does not directly support different file schemes even though its an option on the settings form.

damienmckenna’s picture

Would like to see this progress.

discipolo’s picture

so maybe someone can tell me how to access the settings already in code in includes/media.fields.inc

function media_field_widget_settings_form or
function media_field_widget_form

and put them in includes/media.pages.inc lines 235 & 272 instead of $scheme = variable_get('file_default_scheme', 'public') . '://'; ?

discipolo’s picture

StatusFileSize
new10.65 KB

just for reference:
here is that patch cleaned up and commented. should not destroy anything now.

and as to how to make media working:
can someone explain to me whether it isn`t sufficent to change

media/includes/media.fields.inc line 44 to read 'allowed_schemes' => variable_get('file_default_scheme', 'public'),

recrit’s picture

media/includes/media.fields.inc line 44 -- that needs to be an array since its defining the default selected options for the allowed schemes.

commerce_file_media-1186162-x.patch -- The added functionality is more of a specific integration to media module, so I would suggest creating a new module for it... media_product or something else. As for Commerce File, if it ever does integrate with other file modules it would be a generic interface that doesn't cater to a single module.

discipolo’s picture

i also managed to make media save to private filesystem by simply adding radiobuttons to the uploadbrowser using the instructions from http://drupal.org/node/1139266#comment-4532552 but using the form from

media_field_widget_settings_form($field, $instance) --> $form['allowed_schemes']

instead of the directory. i did this because i couldnt figure out how to get at the widget settings.

should´nt that be viable?

(this is my last media post in this queue, promise!)

gusaus’s picture

I 'think' this also would be the missing piece for an audio download store. Interested in helping in any non-programming sort of way.

audster’s picture

subscribe

torgospizza’s picture

Subscribing. I would like to test the patch in #11 - we sell almost exclusively mp3 downloads and video files, with a subscription / premium content model coming soon. I'd love to be able to offer existing media assets as bonus or premium content. Thanks for all the effort on this so far.

cpelham’s picture

Thanks for working on this!

recrit’s picture

Status: Active » Postponed

the work on getting media module to actually use Drupal core's private file system is taking place in the media issue queue #1069582: How to use an alternate stream wrapper when saving media files?.
As for integration into Commerce File, I honestly do not see what the need is for it.

[1] referencing existing files - You can reference existing files using File Field Sources with Commerce File or any core file field for that matter. Currently it only provides referencing files that were added through that field instance, there are some issues in file field sources queue to open up IMCE source to all files, etc... so could be promising to reference any file uploaded via media.

[2] display - The display of the content to the end user could be handle with file field formatter support - I'm currently working on image formatters (#1225760: Allow image display formatters). However, keep in mind if the original image is displayed on a page, then it counts as download. Likewise, mp3's can be played in a player formatter such as jwplayer... I believe it would count as a download even if they only played a few seconds - would have to test to be sure of this.

[3] existing media - If you have am existing media file, all commerce file field needs is the fid. Some have done some feeds works to accomplish this - #1162602: Feeds support for Commerce File. I will be working on adding feeds targets into Commerce File. Keep in mind if any file is added to a Commerce File field, then download of it is restricted any where it is used.

With all of that in mind... if someone can convince me of keeping this open, then we can re-open. Marking as postponed for now.

discipolo’s picture

Hi, I feel I might have a persuasive argument for allowing commerce_file_fields to use the media widget for upload:

having installed
http://drupal.org/project/commerce_downloads
i am still required to upload images individually. now
http://drupal.org/project/commerce_bpc
seems like a wonderful solution for adding multiple products.
in order to make it useful for a digital download store, commerce_file would have to work as "combinations field" and be able to select multiple files.
the most handy way would seem to use the media modules widget for either

- selecting files from the library
- uploading them via plupload

or have i overlooked a way this could be achieved with filefield_sources already?

toby53’s picture

I would like to attach files I upload via SCP (secure copy) to the commerce product files.
As discussed before (and many other places) filefield sources / IMCE does not currently support the attachment of "un-managed" files.
What is currently recommended ? We need to go live within a month.

discipolo’s picture

@toby filefield sources does allow you to

Attach server-side files uploaded via FTP

or did i misunderstand you?

in general i found FileField Sources Plupload which provides filefieldsources with a massupload option. also i wrote a BPC extension module for using commerce file fields as combination fields in bpc.

so this feature request seems to be resolved. my current approach is documented here:
http://drupal.org/node/1294788

toby53’s picture

Category: feature » support

Thanks for all your work on this project - I'll checkout the links.

Yes we use SCP instead of FTP here. The issue is that they are not "managed" files existing on the server so filefield sources / IMCE cannot seem to use them when attempting to attach them to commerce products (you can attach uploaded files just fine).

Our goal is create commerce products and attach a number of commerce files that exist in a deep directory structure like products/suncode/release1.2/documentation/selfstudy_docs.
I would also like to assign a taxonomy to the files based on their directory structure so they can be displayed in different views.

discipolo’s picture

sounds like you might have to wait for mediamover module then.

bojanz’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Postponed » Fixed

I have published 7.x-2.x (see https://drupal.org/node/1395488#comment-7658191) which allows you to do anything here since it uses a regular filefield.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.