This module uploads a zip of images, files or documents etc. and extracts them to a desired directory. Location of directory can be configured through modules admin configurations.

There are certain situations where a user would require a bulk of files to be
uploaded at server. You can take an example of feed import activity where a user
uploads node using feed importer. There could be an image or file field which
requires files to be uploaded however there is no simple way to move all files
via FTP first and then refer the path of uploaded files in your CSV or excel
files for a specific node to be created.

By using Pack & Upload this process can be very easy just by following the
steps:

1. Create a tar.gz or zip of files you want to upload.
2. Change pack & upload settings and specify a directory where you want to
move all uploaded files.
3. Now go to uploader form, provide path to your pack (zip or tar.gz) and
upload.
4. Once uploading is completed it will extract all files in the specified
directory.

Note: Make sure you have the right permissions to the directory where you want
to upload.

Sandbox Link:
https://drupal.org/sandbox/divesh.kumar/2091701

GIT URL:
git clone --branch 7.x.1.x divesh.kumar@git.drupal.org:sandbox/divesh.kumar/2091701.git pack___upload

Reviews of Other Projects
https://drupal.org/node/2043615#comment-7653461
https://drupal.org/comment/8375895#comment-8375895
https://drupal.org/comment/8384045#comment-8384045

CommentFileSizeAuthor
#3 pack_upload_help.png11.38 KBstockunlocks
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

divesh.kumar’s picture

Status: Active » Needs review
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

stockunlocks’s picture

FileSize
11.38 KB

Hi divesh.kumar:

I'm using Drupal 7.23 and I've installed the module and it works as described.

I just wanted to bring a couple of things to your attention:

First: Like most users, I skimmed over the instructions and jumped right in. I went to the configuration page and saw that the "SETTINGS" tab already had the Bulk Media Extraction Path set to: sites/default/files/bulk_media So, I skipped clicking "Save configuration" and went directly to the "UPLOAD BULK MEDIA" tab. I browsed for my .zip package and clicked "Submit".

The package was uploaded, but not expanded. It was placed as a .zip in the sites/default/files folder instead of where I thought it would go.

I went back to the "SETTINGS" tab and this time clicked "Save configuration" and was presented with the confirmation message. Going through all of the motions again were successful: .zip uploaded and expanded in the sites/default/files/bulk_media where it should have been.

As a small suggestion: Why not disable the "Submit" button if the Media Extraction Path has not been set? You could present a message instead of the Submit button, like: "Please set: Bulk Media Extraction Path first" or something like that. This would prevent orphaned package files from being dumped onto the server.

It is a nice idea to have the path already there, as you have it. No need to guess how it should be formatted if a custom path was desired.

Second: When navigating to /admin/advanced_help/pack_upload, the title of the page is formatted like this: Pack & Upload help index all other pages like this: Pack & Upload. Just a small fix needed. I've included a screenshot below.

Thanks

divesh.kumar’s picture

Hi darrel,

I have made the changes to default media path and the bug is fixed also made the changes to the title as well.

Thanks

pgautam’s picture

Hi Divesh,

.module file
- remove MENU_NORMAL_ITEM as this is default in drupal 7.

Rest seems fine to me.

Thanks,
Paritosh Gautam

Nitesh Pawar’s picture

Hi divesh.kumar

I think you need to create directory by code, But its my thinking if you like then you can use this patch. :-)

@@ -86,6 +87,11 @@
 if ($file) {
+    
+    if (!is_dir(variable_get('pack_upload_bulk_media_path'))) {
+      drupal_mkdir(variable_get('pack_upload_bulk_media_path'), variable_get('file_chmod_directory', 0777));
+    }
+    
     if ($file = file_move($file, variable_get('pack_upload_bulk_media_path'))) {
       $form_state['values']['file'] = $file;
       $realpath = drupal_realpath($file->uri);

Thanks

Ravi.J’s picture

Status: Needs review » Needs work

Hi Divesh,
Couple of points

  1. file_entity already supports this feature via this patch https://drupal.org/node/1741092, looks like there is not much this project can offer over what file_entity already has in place. It will be great if you can collaborate with maintainers of file_entity and discuss any ideas you have for this module with them and find a way of embedding them into file_entity, else this will be another module that does what file_entity already does.
  2. Project does not meet the requirement mentioned in inspiration.
    From the inspiration of project
    There could be an image or file field which
    requires files to be uploaded however there is no simple way to move all files
    via FTP first and then refer the path of uploaded files in your CSV or excel
    files for a specific node to be created.

    Does the module do this now, i.e log the list of files uploaded somewhere so that the list can be used for creating nodes etc ?

divesh.kumar’s picture

Hi Ravi,

Thanks for being taking my contribution into consideration and I really appreciate your time to review this request.

I am aware with the file_entity and I know by making few changes this can be achieved however there could be some scenario where you would require a utility which just takes your package and extracts everything at right place.

Lets take an example there could be a scenario when a person completely wants to move media files to files directory and doesn't have ftp accessibility then my this utility would work for him.

Though its really beneficial in feeds scenario because there no such effective way when you import csv file and if a media is related to a node record there could be problem attaching the image once again.

I know this would be another module to the community however there are plenty of them which does a very small task, btw rounded corner js was one of them.

I would need your help to provide this utility to community.

Thanks
Divesh Kumar

divesh.kumar’s picture

Issue summary: View changes
Status: Needs work » Needs review
ram4nd’s picture

  • pack_upload_install() - all sites don't have that directory.
  • Predefine $items in hook_menu to avoid notices.
klausi’s picture

@ram4nd: you don't need to predefine arrays before using them in PHP, so the hook_menu() implementation is fine. Make sure to verify that a PHP notice actually exists before reporting it next time.

ram4nd’s picture

Ok, I have experienced notices when I don't predefine them in PHP 5. Although I don't remember the case. Also other people have told me so.

brockfanning’s picture

Hi Divesh, I tried out the module, and here is some feedback:

  • Personally think the menu item should go under “Media”, which has become the default for file-related things
  • I get an error when I try to upload something. “File temporary://packed_file.zip (/tmp/packed_file.zip) could not be moved, because the destination sites/default/files/bulk_media is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.”
  • It seems like if this functionality is useful to site-builders, then it may also be useful to users, so could maybe be implemented as additional behvaior on normal file fields - such as the auto-extraction of compressed files. Just a thought, and unrelated to approving/rejecting this application.

If you could shed any light on the error, I'll give it another try. Thanks!

m1n0’s picture

Status: Needs review » Needs work
divesh.kumar’s picture

Hi brockfanning,

Can you please let me know on which case you are getting the upload error as I had tested it on multiple system by changing the permissions and it went well.

And definitely this is useful functionality for users as well and the auto extraction is too a wonderful thoughts which I will definitely include in future release after the initial release.

Thanks

brockfanning’s picture

Hi Divesh, I'm still having the same problem. Here are some details on what I'm doing:

- new Drupal 7 install
- created files directory, chmod 777
- enable pack_upload
- go to upload form, attempt to upload a .zip file, get the same error

- tried saving the config page first, but same result

- tried chmod 777 the bulk_media folder (which the module created for me), same results

- tried uploading an image file on a new node of the "article" content type to make sure that worked, and it did

Here's the error message:
File temporary://pack_upload.zip (/tmp/pack_upload.zip) could not be moved, because the destination sites/default/files/bulk_media is invalid. This may be caused by improper use of file_move() or a missing stream wrapper.

More info:
The files are being uploaded/saved to /tmp but not moved. Environment is Ubuntu 13.10, site is running on Apache 2 using virtual host. The zip file I used is created with the normal Ubuntu "compress" utility.

Hope this helps! Let me know if I should try anything different, or am doing something wrong.

divesh.kumar’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +PAreview: review bonus
klausi’s picture

Assigned: divesh.kumar » patrickd
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

It appears you are working in the "7.x.1.x" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

So the branch name should be "7.x-1.x", not "7.x.1.x".

manual review:

  1. pack_upload_media_upload_form(): doc block is wrong, this is not a hook. See https://drupal.org/node/1354#forms . Same for pack_upload_media_upload_form_submit() and others.
  2. 'No file was uploaded.' is a bit vague for the user, maybe you should ask if they used the correct file extension?
  3. What happens with files that already exist? Do they get overwritten?

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to patrickd as he might have time to take a final look at this.

divesh.kumar’s picture

Issue tags: +PAreview: review bonus

Hi Klausi,

Here are my comments.

  • pack_upload_media_upload_form(): doc block is wrong, this is not a hook. See https://drupal.org/node/1354#forms . Same for pack_upload_media_upload_form_submit() and others. - DONE
  • 'No file was uploaded.' is a bit vague for the user, maybe you should ask if they used the correct file extension? - Fixed and made related error displayed
  • What happens with files that already exist? Do they get overwritten? - Files will get overwritten.

@Brockfanning, Thanks man for consistently helping in testing the module. The file upload should not be a problem now. please check and confirm.

Thanks

patrickd’s picture

Status: Reviewed & tested by the community » Postponed

Sorry for the delay;

I'd recommend you to make the first sentence of your project page a short introduction to what it does, big blocks of text are no good for people who just want to quickly understand what it does and whether they can use it.

(if possible:) when the extraction of a zipfile fails it might be useful if you log some details with watchdog(), just the general error message wont help the maintainer much for fixing the problem.

No critical issues though,

Thanks for your contribution!!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

patrickd’s picture

Status: Postponed » Fixed

woops

brockfanning’s picture

Divesh, I'm still getting the same error. I'm wondering if maybe it's a PHP version issue, as I just noticed that Ubuntu has me at PHP 5.5.3.
- EDIT: Given that nobody else is experiencing this problem, I think it's safe to say it's something specific to my setup. I'll shut up now. :)

divesh.kumar’s picture

Issue summary: View changes
divesh.kumar’s picture

Hi Brockfanning,

Thanks man for your effort in testing. Somehow I am not able to get that error. May be your machine is not happy with you :-P.

Anyways you have been such a great help in getting this module bug free.

Much appreciated!!!

@patrickd, I have made a watchdog logging as suggested.

Status: Fixed » Closed (fixed)

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