Defect #33752 » 33752.patch
| app/controllers/attachments_controller.rb | ||
|---|---|---|
| 105 | 105 |
return |
| 106 | 106 |
end |
| 107 | 107 | |
| 108 |
@attachment = Attachment.new(:file => request.raw_post)
|
|
| 108 |
@attachment = Attachment.new(:file => request.body)
|
|
| 109 | 109 |
@attachment.author = User.current |
| 110 | 110 |
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16) |
| 111 | 111 |
@attachment.content_type = params[:content_type].presence |
| config/initializers/10-patches.rb | ||
|---|---|---|
| 215 | 215 |
end |
| 216 | 216 |
end |
| 217 | 217 |
end |
| 218 | ||
| 219 |
# https://github.com/rack/rack/pull/1703 |
|
| 220 |
# TODO: remove this when Rack is updated to 3.0.0 |
|
| 221 |
require 'rack' |
|
| 222 |
module Rack |
|
| 223 |
class RewindableInput |
|
| 224 |
unless method_defined?(:size) |
|
| 225 |
def size |
|
| 226 |
make_rewindable unless @rewindable_io |
|
| 227 |
@rewindable_io.size |
|
| 228 |
end |
|
| 229 |
end |
|
| 230 |
end |
|
| 231 |
end |
|
| test/integration/api_test/attachments_test.rb | ||
|---|---|---|
| 250 | 250 |
assert attachment.digest.present? |
| 251 | 251 |
assert File.exist? attachment.diskfile |
| 252 | 252 |
end |
| 253 | ||
| 254 |
test "POST /uploads.json should be compatible with an fcgi's input" do |
|
| 255 |
set_tmp_attachments_directory |
|
| 256 |
assert_difference 'Attachment.count' do |
|
| 257 |
post( |
|
| 258 |
'/uploads.json', |
|
| 259 |
:headers => {
|
|
| 260 |
"CONTENT_TYPE" => 'application/octet-stream', |
|
| 261 |
"CONTENT_LENGTH" => '12', |
|
| 262 |
"rack.input" => Rack::RewindableInput.new(StringIO.new('File content'))
|
|
| 263 |
}.merge(credentials('jsmith'))
|
|
| 264 |
) |
|
| 265 |
assert_response :created |
|
| 266 |
end |
|
| 267 |
json = ActiveSupport::JSON.decode(response.body) |
|
| 268 |
assert_kind_of Hash, json['upload'] |
|
| 269 |
token = json['upload']['token'] |
|
| 270 |
assert token.present? |
|
| 271 |
assert attachment = Attachment.find_by_token(token) |
|
| 272 |
assert_equal 12, attachment.filesize |
|
| 273 |
assert File.exist? attachment.diskfile |
|
| 274 |
end |
|
| 253 | 275 |
end |
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »