I am developing a custom upload form that inherits from WrappedFormBase. It is designed to replace CreateEditMediaGalleryPostForm and provide extended functionality specific to the site that I am developing. So far as I am aware, subclassing CreateEditMediaGalleryPostForm was not an option, so I needed to subclass WrappedFormBase instead.
In the DataBind override, I have the following code:
MediaGallery currentMediaGallery = MediaGalleryControlUtility.Instance().GetCurrentMediaGallery(this);
This code always returns null, which leads to my form no longer displaying. I do not know if this is the right way to get the current media gallery or even if I have my form in a configuration to properly retrieve this data. Media Galleries are new to CS2008, so I am not able to apply my (limited) knowledge of CS2007.
The following may also be related to this issue:
- MediaGalleryPostTagsSubForm is not rendering as a SubForm in my form
- UploadPostAttachment.aspx always tells me that I do not have permission to upload a file, even though I am logged in with an admin account. I have checked permissions in Control Panel and turned them all to on.
This is not a bug in CS2008, merely a lack of documentation and understanding on my part of how to properly subclass WrappedFormBase to create a custom Form in the Media Galleries.
First, I'd suggest extending the original CreateEditMediaGalleryPostForm using sub-forms if possible, instead of duplicating the functionality of that control to customize it. An example of using sub-forms to extend an existing form is available at: http://docs.communityserver.org/wiki/page.aspx/312/how-to-extend-user-registration-using-sub-forms/ (this one is dealing with user registration, but the concept is the same for all forms)
jsawruk: In the DataBind override, I have the following code: MediaGallery currentMediaGallery = MediaGalleryControlUtility.Instance().GetCurrentMediaGallery(this); This code always returns null
This code always returns null
Is the control hosted within a media gallery page? That method will only return a MediaGallery if there is one in the current page context. For example, all pages with the "application key" in the URL will have a current media gallery.
If the control is placed on the home page of the site, for example, there is no contextual media gallery to retrieve, so it returns null.
jsawruk:The following may also be related to this issue
These side issues lead me to believe the control is hosted outside of the context of a media gallery.
If you'd really like to get into developing custom Chameleon controls, I would suggest looking at the Professional Community Server Themes book, http://www.amazon.com/Professional-Community-Server-Themes-Wyatt/dp/0470182083
Hi Ben,
It would not be possible to extend CreateEditMediaGalleryPostForm using subforms. I need to override how the form acts when the user clicks the Submit button with my own custom code. Unfortunately, the code that does that in CreateEditMediaGalleryPostForm is private and not virtual, so I will need to create a new form derived from WrappedFormBase.
I created a new page in the video directory using siteurls_override.config. The page is derived from CSMediaGalleryThemePage. Is this not sufficient to have a MediaGallery in the current context? I have absolutely no idea what the "application key" is. It does not appear in any of my media URLs, not even in my default CS2008 install. Maybe I am missing something?
If I could just get a current MediaGallery object, I think my form would work. How do I get it hosted inside a media gallery context?
I read your book; specifically the section on Custom Form Controls (pp. 191-202) before I even started developing this control. Unfortunately, as it does not cover CS2008, it could not provide further insight into how to work with the CS2008 MediaGallery class.
jsawruk:It would not be possible to extend CreateEditMediaGalleryPostForm using subforms. I need to override how the form acts when the user clicks the Submit button with my own custom code. Unfortunately, the code that does that in CreateEditMediaGalleryPostForm is private and not virtual, so I will need to create a new form derived from WrappedFormBase.
What specifically do you want to do? I'm having trouble understanding the situation.
jsawruk: I created a new page in the video directory using siteurls_override.config. The page is derived from CSMediaGalleryThemePage. Is this not sufficient to have a MediaGallery in the current context? I have absolutely no idea what the "application key" is. It does not appear in any of my media URLs, not even in my default CS2008 install. Maybe I am missing something?
CSMediaGalleryThemePage only provides easier access to contextual media gallery data -- it does not create the context of the page. The context of the page is defined by the URL and query string. For example, in the URL,
http://communityserver.org/media/galleries/themes_and_skins/default.aspx
the "themes_and_skins" portion identifies the application key (or name or URL as defined in the control panel) of the media gallery being used. On the upload page,
http://communityserver.org/media/PostAdmin.aspx?App=themes_and_skins
it is a little more apparent -- in the querystring using the App variable name. If the application key (or section ID) does not exist in the URL or querystring, there is no media gallery in the context of the page and it would need to be loaded explicitly using Chameleon or code logic on the page.
jsawruk:If I could just get a current MediaGallery object, I think my form would work. How do I get it hosted inside a media gallery context?
It's not really a matter of placement -- more a matter of what information is passed to the new page. When you access the page, you'll need to pass a querystring parameter identifying the media gallery to work with via the App=appkey or SectionID=id querystring options.
jsawruk: I read your book; specifically the section on Custom Form Controls (pp. 191-202) before I even started developing this control. Unfortunately, as it does not cover CS2008, it could not provide further insight into how to work with the CS2008 MediaGallery class.
All applications (and all objects within those applications) work the same way. There is no hidden logic on the pages that create contexts -- only inferences based on the URL/querystring and controls on the page. Hopefully we can get this better documented soon.
The goal is create a custom way in which media files are uploaded, stored, and retrieved within the Community Server architecture. Community Server already has a lot of media gallery functionality, but it does not meet our current needs. We would prefer to extend CS and build on top of it rather than having to create our own media gallery.
Here is how upload would work:
User selects a video file for upload
The incoming file could be in a number of formats, but there is a converter that takes an input video file and converts to FLV. We then have an FLV player to play those files.
The problem is this. Let's say the user uploads a QuickTime file (.mov). Currently, CommunityServer stores a reference to the .mov file. However, we want to convert the .mov to .flv and store a reference to the .flv instead.
The sequence would be: 1) Use CS to upload the .mov file, 2) Convert the .mov to .flv, 3) Use CS to Add the .flv to the MediaGallery, 4) Delete the .mov file.
Currently, CS's upload control both uploads the file and immediately adds it to the MediaGallery. We need to intercept this process so that we can upload one file but inform CS that we are adding a different file to the MediaGallery.
The Video Exchange on Avid's website (http://www.avid.com/exchange/files/) already appears to support this functionality. They also appear to be running an older version of CS, so I am not entirely sure if we could directly adapt their technique.
I would like to have a URL like this:
http://www.thesite.com/media/upload.aspx
There shouldn't be any query string parameters.
Let me second that customizing the uploader functionality would be useful in many scenarios.
- For example the ability to display progress while uploading, maybe using a tiny flash control or some kind of ajax.
- The ability to immediately process the media that was uploaded into another form. This is quite a common pattern for media uploads.
thanks for listening.
cool ecards
jsawruk: The sequence would be: 1) Use CS to upload the .mov file, 2) Convert the .mov to .flv, 3) Use CS to Add the .flv to the MediaGallery, 4) Delete the .mov file.
I actually had an internal discussion today about this very situation. Here's the flow we talked about:
This approach allows the file to be rendered anywhere viewers are supported (in post content, using the <CSMedia:MediaGalleryPostViewer /> control, in content parts, in HTML widgets, etc) and keeps the original file if a full-site re-transcoding is neccessary. It also requires no core changes or overrides.
The re-use of the CFS file store mechanism (to store both the original and transcoded file) is similar to the process used by the ImageFileViewer which stores resized versions of uploaded files back into the post attachment's file store. Another known file storage location could also be used to store the transcoded files -- the FileViewer just needs to know where to look for the final, transcoded verion of the file.
Greetings:- For example the ability to display progress while uploading, maybe using a tiny flash control or some kind of ajax.
To do this, an override/replacement of the base create media gallery post form would need to be used. Because a media gallery post *requires* a file, the upload portion of the form cannot be moved to a sub-form as with other applications (forums and blogs use a SubForm control to handle the attachment uploading).
That said, there *is* a slightly hidden gem in CS2008 -- the <CSMedia:CreateMultipleMediaGalleryPostsForm /> which supports uploading multiple files at once and displays a status bar for each upload (via a Flash/Javascript solution). This control is supported in the front UI but is currently only used in the media gallery control panel.
Ben Tiedt:Use the standard control to upload the original file and store the original file Handle the PostAttachment created event (requires beta-2) using a CSModule to signal the transcoder to process the file and save the transcoded file back into the PostAttachments Centralized File System file store using a known naming convention, such as [Original_File_Name].FLV (or use whatever extension is neccessary for the transcoded output)
That's great. Approximately when do you anticipate beta 2? Is it likely that it will be released before May?
jsawruk:Approximately when do you anticipate beta 2? Is it likely that it will be released before May?
An exact date is not yet available, but, "before May" is a *very* safe bet.
Do you have any recommendations of a workaround until then?
jsawruk:Do you have any recommendations of a workaround until then?
Not a very good workaround, no. You could implement a background task that periodically checks for newly updated PostAttachments in the cs_PostAttachment table and send the appropriate ones to the transcoder.
You mentioned using the PostAttachment event.
Could I use CSEvents.AfterPostAttachment ?
jsawruk:Could I use CSEvents.AfterPostAttachment ?
Yes, that is what you should use with beta-2. There is a bug in beta-1 that causes these post attachment events not to fire.
After I upload a file to the server, how do I find the full path name of the uploaded file on the server? Also, what do all of those subdirectories mean?
Copyright© 2008 Telligent Systems Inc. All rights reserved CommunityServer.com • Telligent.com