プロジェクト

全般

プロフィール

Vote #78250

完了

Support upload of empty files and fix invalid API response

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Attachments_19
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
19
version_id:
125
issue_org_id:
25115
author_id:
40856
assigned_to_id:
1
comments:
5
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.


journals

--------------------------------------------------------------------------------
This patch also fixes the issue reported as #5969.
--------------------------------------------------------------------------------
Here's an extended version of the patch. This one also removes the file size check in acts_as_attachable which prevented empty attachment creation for http uploads without javascript (in all other cases this part of the code isn't relevant since @save_attachments@ is called with just the tokens of already saved attachments).

This patch replaces the original one.
--------------------------------------------------------------------------------
Patch committed, thanks.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,5969,Attachments with size zero are ignored

Admin Redmine さんが3年以上前に更新

  • カテゴリAttachments_19 にセット
  • 対象バージョン3.3.3_125 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0