Feature #7056

Download all attachments at once

Added by Chris Haverman over 9 years ago. Updated 14 days ago.

Status:ReopenedStart date:2010-12-06
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Attachments
Target version:4.2.0
Resolution:Fixed

Description

Did a quick search to see if this had been reported; didn't see anything.

Basically I'd like there to be a way to download all attachments to an issue in a single click rather than each one separately.

compress_the_all_attachments_in_issue.patch Magnifier (8.93 KB) Mizuki ISHIKAWA, 2018-10-11 07:26

compress_the_all_attachments_in_issue_v2.patch Magnifier (12.9 KB) Mizuki ISHIKAWA, 2018-12-25 03:31

error_message.png (287 KB) Mizuki ISHIKAWA, 2018-12-25 03:45

compress_the_all_attachments_in_issue_v3.patch Magnifier (12.9 KB) Mizuki ISHIKAWA, 2019-12-20 01:57

screenshot-v4.png (104 KB) Go MAEDA, 2020-02-18 08:42

compress_the_all_attachments_in_issue_v4.patch Magnifier (13.5 KB) Go MAEDA, 2020-02-18 08:42

compress_the_all_attachments_in_issue_v5.patch Magnifier (13.2 KB) Go MAEDA, 2020-03-07 16:10

compress_the_all_attachments_in_issue_v6.patch Magnifier (13.2 KB) Go MAEDA, 2020-03-14 05:27

attachments-that-causes-EntryExistsError@2x.png (50.7 KB) Go MAEDA, 2020-03-15 03:16

compress_the_all_attachments_in_issue_v7.patch Magnifier (13.2 KB) Go MAEDA, 2020-03-15 03:25

download.png (152 KB) Marius BALTEANU, 2020-03-15 14:12

diff_v7_and_v8.patch Magnifier (2.32 KB) Mizuki ISHIKAWA, 2020-03-17 02:50

compress_the_all_attachments_in_issue_v8.patch Magnifier (13.4 KB) Mizuki ISHIKAWA, 2020-03-17 02:50

human-readable-file-size.patch Magnifier (1.85 KB) Go MAEDA, 2020-03-22 04:52

file-size-before@2x.png (68 KB) Go MAEDA, 2020-03-22 04:52

file-size-after@2x.png (67.1 KB) Go MAEDA, 2020-03-22 04:52

download_all_fix.patch Magnifier - fix Errno::EACCES (3.81 KB) Pavel Rosický, 2020-03-24 21:50


Related issues

Related to Redmine - Feature #8708: Provide a "download multiple files at once" feature Reopened 2011-06-29
Duplicated by Redmine - Feature #2662: Download a document Closed 2009-02-04

Associated revisions

Revision 19601
Added by Go MAEDA 18 days ago

Download all attachments at once (#7056).

Patch by Mizuki ISHIKAWA.

Revision 19602
Added by Go MAEDA 18 days ago

Update locales (#7056).

Revision 19603
Added by Go MAEDA 17 days ago

Update rubyzip to 2.3 (#7056).

Revision 19609
Added by Go MAEDA 16 days ago

Display bulk_download_max_size in human-readable representation (#7056).

Patch by Go MAEDA.

Revision 19631
Added by Go MAEDA 6 days ago

Replace File#readable? with Attachment#readable? (#7056).

Revision 19635
Added by Go MAEDA 6 days ago

Replace File#readable? with Attachment#readable? (#7056).

History

#1 Updated by zac folk over 9 years ago

I agree, this would be really useful.

#2 Updated by Motaz Abuthiab about 7 years ago

+1

#3 Updated by Nicolas QUETGLAS over 6 years ago

+1

#4 Updated by Go MAEDA about 5 years ago

  • Related to Feature #8708: Provide a "download multiple files at once" feature added

#5 Updated by Nikolay Yurchenko almost 3 years ago

+1

#6 Updated by Klément Grisel over 1 year ago

+1

#7 Updated by Mizuki ISHIKAWA over 1 year ago

In order to realize this feature, I thought of compressing and downloading Issue's attachment.
By applying this patch, you can download all of the attached files as a zip file. (using gem rubyzip)

Non-ascii file names are garbled in older versions (Windows 7, Windows Vista, Windows XP).
Windows 7 is scheduled to end support in 2020.
https://github.com/rubyzip/rubyzip/wiki/Files-with-non-ascii-filenames

Any feedback on this patch is welcome.

#8 Updated by Go MAEDA over 1 year ago

Thank you for posting the patch. Could you explain why attachments_to_zip method creates temporary files in Attachment.storage_path instead of tmp directory?

#9 Updated by Go MAEDA over 1 year ago

I think the patch should consider the free space of the disk. Suppose that the total size of attachments of the issue is 1GB. If the free space of the disk is less than 1GB, the creation of a zip archive will fail and the server may stop working due to disk full.

Here are some ideas to avoid the problem.

  • Show an error message indicates no sufficient disk space if the total size of attachments exceeds the free disk space
  • Create and send a zip archive without creating a temporary file

#10 Updated by Mizuki ISHIKAWA over 1 year ago

Go MAEDA wrote:

Thank you for posting the patch. Could you explain why attachments_to_zip method creates temporary files in Attachment.storage_path instead of tmp directory?

There was no particular reason. I changed the temporary file storage location to the tmp directory.

Go MAEDA wrote:

I think the patch should consider the free space of the disk. Suppose that the total size of attachments of the issue is 1GB. If the free space of the disk is less than 1GB, the creation of a zip archive will fail and the server may stop working due to disk full.

Here are some ideas to avoid the problem.

  • Show an error message indicates no sufficient disk space if the total size of attachments exceeds the free disk space
  • Create and send a zip archive without creating a temporary file

Thank you for your feedback.

Because I could not think of a good way to check disk space, I thought about limiting the maximum capacity of temporary files.

The maximum capacity of temporary file can be set in configration.yml.
By doing this setting, it is impossible to create a temporary file larger than the assumption of the server administrator.

#11 Updated by Go MAEDA about 1 year ago

  • Target version set to Candidate for next major release

#12 Updated by Go MAEDA 4 months ago

Mizuki ISHIKAWA wrote:

Non-ascii file names are garbled in older versions (Windows 7, Windows Vista, Windows XP).

I don't think this is a problem because Windows 7 is going to reach EOL next month (2020-01-14).
https://www.microsoft.com/en-us/microsoft-365/windows/end-of-windows-7-support

#13 Updated by Mizuki ISHIKAWA 4 months ago

I modified the patch to apply to the latest trunk.

#14 Updated by Go MAEDA about 1 month ago

I have changed the patch:

  • Add a label to the bulk download button
  • Move the button to below the attachments list (like usability plugin)
  • Updated messages
  • Raised the default value for bulk_download_max_size to 512MB

#15 Updated by Go MAEDA about 1 month ago

#16 Updated by Go MAEDA about 1 month ago

I have updated the patch. Moved bulk_download_max_size setting from configuration.yml to /settings GUI for consistency.

#17 Updated by Go MAEDA about 1 month ago

  • Target version changed from Candidate for next major release to 4.2.0

Setting the target version to 4.2.0.

#18 Updated by Go MAEDA 25 days ago

Slightly updated the patch:

  • Changed the method name Attachment.attachments_to_zip to Attachment.archive_attachments because attachments_to_zip is too specific. No one knows if the feature uses ZIP format forever, so I think the method name should not depend on a specific archive format
  • Changed the text for label_download_all_attachments from "Download all attached files" to simpler "Download all files"

#19 Updated by Go MAEDA 24 days ago

The patch may raise Zip::EntryExistsError when you try to download a ZIP file if a file that has "(2)" suffix in its basename is attached.

Started GET "/attachments/issues/32/download" for 127.0.0.1 at 2020-03-15 10:59:03 +0900
Processing by AttachmentsController#download_all as HTML
.
.
.
Completed 500 Internal Server Error in 28ms (ActiveRecord: 4.9ms)

Zip::EntryExistsError (add failed. Entry testfile(2).txt already exists):

app/models/attachment.rb:362:in `block (2 levels) in archive_attachments'
app/models/attachment.rb:355:in `each'
app/models/attachment.rb:355:in `block in archive_attachments'
app/models/attachment.rb:354:in `archive_attachments'
app/controllers/attachments_controller.rb:139:in `block in download_all'
app/controllers/attachments_controller.rb:138:in `download_all'
lib/redmine/sudo_mode.rb:64:in `sudo_mode'

I have fixed the above issue. Also, I have changed the "(n)" suffix for duplicate filenames to start from 1 instead of 2. It is the same behavior as Chrome and Firefox do when downloading files with the same name.

#20 Updated by Marius BALTEANU 23 days ago

I like this feature.

What do you think if we show the link next to edit attached files icon (as Mizuki proposed first time) in order to keep the links grouped?

I don't find very UX friendly to have the Edit button to the right and the "Download all" button under attachments and thumbnails.

#21 Updated by Marius BALTEANU 23 days ago

  • Related to deleted (Feature #8708: Provide a "download multiple files at once" feature)

#22 Updated by Marius BALTEANU 23 days ago

  • Duplicated by Feature #8708: Provide a "download multiple files at once" feature added

#23 Updated by Marius BALTEANU 23 days ago

Also, we should add a test for the new route added by this patch.

#24 Updated by Marius BALTEANU 23 days ago

  • Duplicated by deleted (Feature #8708: Provide a "download multiple files at once" feature)

#25 Updated by Marius BALTEANU 23 days ago

  • Related to Feature #8708: Provide a "download multiple files at once" feature added

#26 Updated by Go MAEDA 23 days ago

Marius BALTEANU wrote:

What do you think if we show the link next to edit attached files icon (as Mizuki proposed first time) in order to keep the links grouped?

I prefer the current position becuase the position you suggest is very far from the list of files and many people may not notice this useful feature. But it is OK to move the button to the right if we can move this patch forward by doing that.

#27 Updated by Marius BALTEANU 23 days ago

Go MAEDA wrote:

Marius BALTEANU wrote:

What do you think if we show the link next to edit attached files icon (as Mizuki proposed first time) in order to keep the links grouped?

I prefer the current position becuase the position you suggest is very far from the list of files and many people may not notice this useful feature. But it is OK to move the button to the right if we can move this patch forward by doing that.

I agree with you that having all the action icons in the right corner is maybe not the best option, but this is in the current UI and we cannot just drop some action icons in other places. We should keep the consistency and if we do a change to resolve the distance, we should do it for all the icons because there is no difference between the Edit icon and Delete icon. In all other screens we have the icons one after each other. From my point of view, we can commit this if we move the icon and add the missing test.

#28 Updated by Mizuki ISHIKAWA 22 days ago

Thanks for contributions for releasing this feature.

I updated the patch.
  • Add tests to test/integration/routing/attachments_test.rb
  • Move icon position to original position

#29 Updated by Go MAEDA 18 days ago

  • Subject changed from Download All Attachments in Issue to Download all attachments at once
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch. Thank you for improving Redmine.

#30 Updated by Go MAEDA 17 days ago

The attached patch human-readable-file-size.patch fixes the format of file size in the message error_bulk_download_size_too_big to human-readable.

Before:

After:

#31 Updated by Go MAEDA 16 days ago

  • Status changed from Reopened to Closed

Go MAEDA wrote:

The attached patch human-readable-file-size.patch fixes the format of file size in the message error_bulk_download_size_too_big to human-readable.

Committed the patch in r19609.

#32 Updated by Pavel Rosický 14 days ago

unfortunately, this feature doesn't work on Windows.

Error:
AttachmentTest#test_archive_attachments:
Errno::EACCES: Permission denied @ rb_file_s_rename - (c:/redmine/tmp/attachments_zip20200324-12432-yknlax20200324-12432-1qjlddf, c:/redmine/tmp/attachments_zip20200324-12432-yknlax)
    app/models/attachment.rb:355:in `archive_attachments'
    test/unit/attachment_test.rb:284:in `block in test_archive_attachments'
    test/unit/attachment_test.rb:283:in `test_archive_attachments'

I've attached a quick fix.

#33 Updated by Go MAEDA 14 days ago

  • Status changed from Closed to Reopened

Also available in: Atom PDF