Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Title: Missing upload progress » Add upload progress to the Upload tab
Version: 7.x-1.0-rc2 » 7.x-2.x-dev
Component: User interface » Media Browser
Category: bug » feature

Because there is no upload progress enabled on the Upload tab of the media browser, so this is not a bug, it is a feature request.

Dave Reid’s picture

Marked #1471908: No Upload progress indicator on media browser as a duplicate of this issue.

rlmumford’s picture

Assigned: Unassigned » rlmumford

Myself and AndrewBelcher are having a look at this at the moment. If anyone has any pointers they would be appreciated,

rlmumford’s picture

Assigned: rlmumford » Unassigned

We spent a few hours playing with this.

Is there a reason the upload form element is of type 'file' rather than 'managed_file'?

We changed this and eventually got the file uploading (with the throbber/progress bar as provided by that element). However, once the file had been uploaded, we would recieve an error saying the file could not be moved (Triggered in line 1551 of includes/file.inc - file_upload_save())

Does anyone have any thoughts?

rlmumford’s picture

Here's the patch we worked on so far, so many hours, so little code :(

Dave Reid’s picture

Status: Active » Needs review
FileSize
4.25 KB

I think I have this working. Please test the following patch.

rlmumford’s picture

A few problems,

If I click the upload link:
I see the upload bar (as expected). Once the upload is complete the input box vanishes, and I'm left with the Submit and Cancel buttons. If I click submit, I get taken (eventually back to the media library, without the file present).

If I click submit:
The upload works, and the media gets put into the file field. But no pregress bar.

Dave Reid’s picture

Status: Needs review » Needs work

Yeah it works fine when used on file/add/upload but in the Media browser I get the following errors:

Notice: Undefined index: media_add_upload in drupal_retrieve_form() (line 752 of /home/dave/Dropbox/Projects/drupal7dev/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'media_add_upload' not found or invalid function name in drupal_retrieve_form() (line 787 of /home/dave/Dropbox/Projects/drupal7dev/includes/form.inc).
Notice: Undefined index: upload in file_ajax_upload() (line 270 of /home/dave/Dropbox/Projects/drupal7dev/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 279 of /home/dave/Dropbox/Projects/drupal7dev/modules/file/file.module).
andrewbelcher’s picture

Status: Needs work » Needs review

Ah, I got that, you need to add media/includes/media.pages.inc into the form_state build files...

andrewbelcher’s picture

Status: Needs review » Needs work

I'm pretty sure I didn't change any status...

andrewbelcher’s picture

Ok, so I've updated your patch with the build info stuff... However now there is a broken redirect :( I'm not quite sure what other bits you do on submit, or if that is something completely different breaking it. It redirects you to the file edit page.

andrewbelcher’s picture

Ok... so I should have looked at the code, I see where it redirects there now... At the bottom of the media_add_upload_submit function. < 30 lines below my edits. :(

However, in the media browser, it shouldn't be redirecting there, so my guess would be the destination query var isn't set properly. I'm not sure if that's something you've just changed Dave (the patch didn't look like it), so I'll let you look at it before I break anything else, as I'm not sure where it was setting that previously!

Dave Reid’s picture

The media_form_alter() function should be intercepting that redirect and modifying it to make a 'browser submit' redirect.

rlmumford’s picture

Yeah, so if you go to browser and an fid is set it closes the browser and passes the fid back?

rlmumford’s picture

So the problem is, media_form_alter doesn't seem to be getting run when the form gets submitted. In the $form array on the media browser there are two submit handlers set; media_add_upload_submit and media_browser_submit

However, when printing out $form from inside media_add_upload_submit, media_browser_submit is not in the actions array. Any ideas?

rlmumford’s picture

Status: Needs work » Needs review
FileSize
5.35 KB

So it was to do with the managed file ajax requests having different paths to media/browser. This patch seems to work!

gmclelland’s picture

Patch in #16 works for me.

gmclelland’s picture

Dave Reid’s picture

Issue tags: +sprint, +Media Initiative
dgorton’s picture

This will need to be re-rolled after the upload moves to the file_entity module. See #1552920: Move file/add from media to file. and #1552988: Move file/add from media to file

dgorton’s picture

Two patches now - one to the File_Entity module and one to Media. Uploading both here.

mtift’s picture

Status: Needs review » Reviewed & tested by the community

I applied both patches and tested with 100 MB, 250 MB, and 1 GB files.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/file_entity.pages.incundefined
@@ -77,65 +80,25 @@ function file_entity_add_upload($form, &$form_state, $params = array()) {
+  $form_state['build_info']['files']['file_entity_upload'] = drupal_get_path('module', 'file_entity') . '/file_entity.pages.inc';

I think we can actually replace this with the following simpler statement:

form_load_include($form_state, 'inc', 'file_entity', 'file_entity.pages.inc');

dgorton’s picture

Rerolled per #23 - small change though:

form_load_include($form_state, 'inc', 'file_entity', 'file_entity.pages');

mtift’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed with the changes (after I pulled file_entity part, which was recently committed) and it continues to work.

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed
MXT’s picture

I've just upgraded to last dev version but I can't view any progress bar in my media file field.

Where is it?

In drupal default "image" field I've had an option to set:

Progress indicator

  • Throbber
  • Bar with progress meter

But where I can find similar option for my media file field?

Thank you

Status: Fixed » Closed (fixed)

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

itaine’s picture

@MXT - Coming across the same issue. Anyone correct me if I'm wrong. Don't think this particular issue is addressing the option of progress indicator. I take it, this commit shows the progress meter if you have "uploadprogress" enabled on your server. It does show the "Bar with progress meter" during file upload on my end. However, I don't have the option in field settings to switch between it and throbber. I guess that would be another issue feature request :-D.

TechNikh’s picture

Status: Closed (fixed) » Active

I am getting the same error on this page. /admin/workbench/media/add

    Notice: Undefined index: media_add_upload in drupal_retrieve_form() (line 765 of /*****/includes/form.inc).
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'media_add_upload' not found or invalid function name in drupal_retrieve_form() (line 800 of /******/includes/form.inc).

Media 7.x-2.0-unstable6
Workbench Media 7.x-1.0
Media Browser Plus for Media 2.x 7.x-2.x-dev
File entity 7.x-2.0-unstable6
Workbench Files 7.x-1.0

Dave Reid’s picture

Dominick R’s picture

The last submitted patch, 16: 1394826-upload-use-managed-file-element-3.patch, failed testing.