Project

General

Profile

Actions

Patch #25115

closed

Support upload of empty files and fix invalid API response

Added by Jens Krämer about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Category:
Attachments
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

When Uploading an empty file through the REST API (POST to /uploads.json), the response is 201 Created, and an invalid token (which that does not resolve to an attachment through Attachment.find_by_token because it lacks the digest component) is returned. However an attachment record is still saved, but without a corresponding file in the file system.

When looking into this I found that the easiest fix for this would be to change the two conditionals in attachment.rb that prevent an empty file from being treated like any non-empty file. I don't see any technical reason to not allow the uploading of empty files, and my change doesn't seem to cause any of the existing tests to fail.

Attached is a patch which does that, including a test case illustrating the inconsistent API behavior I described above.


Files

0001-fixes-uploading-of-empty-files.patch (2.65 KB) 0001-fixes-uploading-of-empty-files.patch Jens Krämer, 2017-02-17 15:23
0001-fixes-uploading-of-empty-files-v2.patch (3.61 KB) 0001-fixes-uploading-of-empty-files-v2.patch extended patch with acts_as_attachable fix Jens Krämer, 2017-02-19 08:02

Related issues

Related to Redmine - Defect #5969: Attachments with size zero are ignoredClosed2010-07-27

Actions
Actions

Also available in: Atom PDF