Defect #5969

Attachments with size zero are ignored

Added by Yuriy Vidineev about 11 years ago. Updated over 4 years ago.

Status:ClosedStart date:2010-07-27
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Attachments
Target version:-
Resolution:Fixed Affected version:

Description

How to reproduce:
- create file with zero size (for example, in Linux: touch redmine_test_file.txt)
- try to add this file to existing issue

Results:Issue has not any uploaded file

I have Redmine 1.0.0 on Debian Lenny with mongrel and MySQL 5.0

Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.4
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /var/www/redmine-1.0.0
Database adapter mysql
Database schema version 20100705164950

About your Redmine plugins
Redmine Graphs plugin 0.1.0
Simple CI 1.0
Redmine Charts 0.1.0
Scrumdashboard plugin 1.2
Mylyn Connector plugin 2.6.4.trunk.423

In production.log i can see this:

Processing IssuesController#update (for X.X.X.X at 2010-07-27 08:05:14) [PUT]
Parameters: {"time_entry"=>{"comments"=>"", "activity_id"=>"", "hours"=>""}, "commit"=>"Принять", "notes"=>"", "action"=>"update", "_method"=>"put", "authenticity_token"=>"Kieyq
oJZuBzsxZldQfF/7ijY4Dj4U4EWWDss06SHiSo=", "id"=>"10758", "issue"=>{"start_date"=>"2010-07-26", "custom_field_values"=>{"8"=>"2010-07-27"}, "estimated_hours"=>"", "priority_id"=>"6
", "parent_issue_id"=>"", "lock_version"=>"8", "fixed_version_id"=>"", "done_ratio"=>"0", "assigned_to_id"=>"8", "subject"=>"Test Task ", "category_id"=>"126", "tracker_id"=>"14", "due_date"=>"", "status_id"=>"2", "description"=>"Test Test"}, "controller"=>"issues", "attachments"=>{"1"=>{"file"=>#<File:/tmp/RackMultipart20100727-28985-l0uv9f-0>, "description"=>"test file"}}}
Redirected to http://prj.slweb.ru/issues/10758
Completed in 340ms (DB: 48) | 302 Found [http://prj.slweb.ru/issues/10758/edit]

If i do:
echo 1 > redmine_test_file.txt
then this file can be added successfully.

P.S. Sorry for my English
Thank you!

0001-allow-upload-of-zero-byte-files-as-attachments.patch Magnifier (2.92 KB) Jens Krämer, 2016-08-31 03:23


Related issues

Related to Redmine - Patch #23718: do not ignore zero byte attachments Closed
Related to Redmine - Patch #25115: Support upload of empty files and fix invalid API response Closed
Duplicated by Redmine - Defect #10312: Can not attach empty files. Closed

History

#1 Updated by Felix Schäfer about 11 years ago

If this updates adds an empty file, I can't reproduce the issue.

#2 Updated by Felix Schäfer about 11 years ago

  • Subject changed from Could not upload file with zero size into existing issue to Attachments with size zero are ignored
  • Category set to Attachments
  • Affected version (unused) set to devel

Ok, my precedent note should have included an empty attachment, so I can reproduce this issue.

#3 Updated by Holger Just about 11 years ago

This is because of source:trunk/app/models/attachment.rb#L147

Attachments with size zero are explicitly ignored.

#4 Updated by Felix Schäfer about 11 years ago

Any reason for not uploading null-sized attachments, or on the other hand any reason for wanting to upload null-sized files?

#5 Updated by Yuriy Vidineev about 11 years ago

We want to upload google verification files - files with special name and zero size

#6 Updated by Felix Schäfer about 11 years ago

IIRC google verification files have to live in the root of the URI you want to verify, for that you'd need to put the file in redmine_dir/public/.

#7 Updated by Yuriy Vidineev about 11 years ago

I may not correctly put. I don't wont to verify my Redmine. I want to verify my another website and add google verification file to task in Redmine. But i can't add this file to task because it has zero size.
P.S. Sorry for my English

#8 Updated by Felix Schäfer about 11 years ago

Well, you could just save the filename in a wiki or wherever, and I think google retains means to download the files even long after they have been activated ;-)

Anyway, Holger, do you see any reason to not allow zero-sized files?

#9 Updated by Holger Just about 11 years ago

I still do not see the point why you would want that. Also, the file you downloaded from google is not a zero byte file. It at least contains the code that is also present in the filename.

But I see no technical reasons why a zero byte file would not be possible, apart from possibly obscure browser bugs of course. Also, I just traced the code back to the initial revision, so we can also safely fall back to "we always did it that way" :) See source:trunk/redmine/app/controllers/documents_controller.rb@4#L46

#10 Updated by Daniel Felix almost 9 years ago

  • Status changed from New to Needs feedback

Any news on this? Should this be corrected or is this excluded by design?

#11 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from Needs feedback to Confirmed

I mark this as confirmed as there's no good reason to ignore empty files.

#12 Updated by Go MAEDA over 6 years ago

#13 Updated by Stephen Ostrow over 6 years ago

Felix Schäfer wrote:

Any reason for not uploading null-sized attachments, or on the other hand any reason for wanting to upload null-sized files?

Figured I would add another use-case as an example and why I went looking to see if this bug was already filed. Over the past month or so I've been uploading 4 files when running an operation.

  1. before.txt
  2. operation.log
  3. after.txt
  4. result.diff

Where result.diff is a diff of the before.txt and the after.txt files. When there is no difference then the .diff file is empty (0b) and although I still want it uploaded to show that fact, redmine is silently ignoring the upload.

I personally would like for redmine to upload 0b files since I can't think of a good reason for it not to. But more so I would say it is a bug that it silently ignores the 0b file after showing you that it has been added to the issue.

#14 Updated by Jens Krämer about 5 years ago

Submitted a patch that fixes this in #23718

#15 Updated by Jens Krämer about 5 years ago

attaching the patch here as requested :)

#16 Updated by Jan from Planio www.plan.io about 5 years ago

  • Related to Patch #23718: do not ignore zero byte attachments added

#17 Updated by Jan from Planio www.plan.io about 5 years ago

  • Target version set to Candidate for next minor release

#18 Updated by Go MAEDA over 4 years ago

  • Related to Patch #25115: Support upload of empty files and fix invalid API response added

#19 Updated by Go MAEDA over 4 years ago

  • Status changed from Confirmed to Closed
  • Target version deleted (Candidate for next minor release)
  • Resolution set to Fixed

Fixed by #25115 for 3.3.3 and 3.4.0.

Also available in: Atom PDF