aws-sdk-ruby icon indicating copy to clipboard operation
aws-sdk-ruby copied to clipboard

[MediaStore] Chunked Transfer Coding does not work

Open kuu opened this issue 7 years ago • 8 comments

Issue description

HTTP 1.1 Chunked Transfer Coding does not get enabled when calling MediaStoreData.PutObject

Gem name and its version

aws-sdk-3.0.1

Version of Ruby, OS environment

ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin17]

Code snippets / steps to reproduce

require 'aws-sdk'

client = Aws::MediaStoreData::Client.new({
  endpoint: SERVICE_ENDPOINT,
  access_key_id: ACCESS_KEY_ID,
  secret_access_key: SECRET_ACCESS_KEY
})

def upload(filePath, mimeType, targetPath)
  File.open(filePath) {|f|
    client.put_object({
      body: f,
      path: targetPath,
      content_type: mimeType,
      upload_availability: "STREAMING"
    })
  }
end

Steps to repro:

  • Send a 10MB file to MediaStore container with the above code
  • Inspect the HTTP request

Expected Behavior:

  • "Transfer-Encoding: chunked" is added to the request header
  • The request body is divided into multiple chunks

Actual Behavior:

  • No "Transfer-Encoding: chunked"
  • "Content-Length" is added to the request header
  • The request body is a single chunk

kuu avatar Jun 10 '19 09:06 kuu

Thanks for the report!

Transfer-Encoding and related trait are supported since core gem version 3.52.0 and at aws-sdk-medialive here since 1.15.0.

Currently,Transfer-Encoding header will be populated when v4-unsigned-body is marked for the streaming operation, not requiring length and when the body size is not available. MediaStore's API model haven't been updated to echo those markers yet, so SDK is not enabled with the behavior. Once service side updates their models, SDK will pick up the behavior automatically.

cjyclaire avatar Jun 10 '19 17:06 cjyclaire

Thanks @cjyclaire for the comment. Sorry, I still don't understand why the Transfer-Encoding header was not added with my code. Even though some updates are still needed on service side, at least the request header should be added by the SDK, right?

I checked the versions of the installed gems which look good:

$ gem list
...
aws-sdk-core (3.54.2)
aws-sdk-medialive (1.33.0)
aws-sdk-mediastore (1.15.0)
aws-sdk-mediastoredata (1.15.0)

Can you guide me how I can change my code to fulfill the conditions you stated?

Transfer-Encoding header will be populated when v4-unsigned-body is marked for the streaming operation, not requiring length and when the body size is not available.

kuu avatar Jun 11 '19 01:06 kuu

Sorry for the confusion, I'm suggesting service model (provided by them) used in SDK, not server side behavior, is missing those required updates.

cjyclaire avatar Jun 11 '19 16:06 cjyclaire

Thanks @cjyclaire for the comment. Sorry, I'm still getting confused...

I can see the JSON file for the MediaStoreData.PutObject is declared here.

Do you mean Transfer-Encoding: chunked will be populated if I modify this file and rebuild the SDK?

kuu avatar Jun 12 '19 00:06 kuu

@cjyclaire Just to confirm, Currently, MediaStoreData.PutObject in ruby sdk does not support Transfer-Encoding and we need to wait for updates on the service model. Is my understanding correct?

kuu avatar Jun 18 '19 02:06 kuu

@kuu apologies for the delay, correct, I'll ping the thread once their model has been updated!

cjyclaire avatar Jun 18 '19 17:06 cjyclaire

It seems like this issue was dropped. Is this still a problem? I see that the authtype is provided in MediaStoreData PutObject but I'm not sure where the service team would need to add authtype in MediaStore api.

mullermp avatar Feb 07 '20 21:02 mullermp

I think that this was a bug in the SDK. It looks like that anything that responds to size will pass param validation, and when going to the plugin, checking #size will not fail and then the header was never added. The plugin expected #size to fail some times. I removed the restriction of checking for respond_to?(:size) in the param validator, so that actual IO objects can be passed in, and then those IO objects may not respond to size, triggering the plugin correctly.

mullermp avatar Feb 11 '20 21:02 mullermp