Revision f4f280ce src/market_mad/remotes/s3/import

View differences:

src/market_mad/remotes/s3/import
68 68
signature_version = xpath(xml, 'MARKETPLACE/TEMPLATE/SIGNATURE_VERSION')
69 69
endpoint          = xpath(xml, 'MARKETPLACE/TEMPLATE/ENDPOINT')
70 70
force_path_style  = xpath(xml, 'MARKETPLACE/TEMPLATE/FORCE_PATH_STYLE')
71
read_length       = xpath(xml, 'MARKETPLACE/TEMPLATE/READx_LENGTH')
71 72

  
72 73
name   = "marketapp-#{id}"
73 74
source = "s3://#{bucket}/#{name}"
74 75

  
75
# Upload
76

  
77
READ_LENGTH = 10*1024*1024 # Read in chunks of 10MB
78

  
79 76
s3_config = {
80 77
    :region            => region,
81 78
    :access_key_id     => access_key_id,
......
86 83
s3_config[:endpoint]          = endpoint if !endpoint.to_s.empty?
87 84
s3_config[:force_path_style]  = true if force_path_style.to_s.downcase == "yes"
88 85

  
86
DEFAULT_READ_LENGTH = 32*1024*1024 # Read in chunks of 32MB
87

  
88
if read_length.to_s.empty?
89
    read_length = DEFAULT_READ_LENGTH
90
else
91
    read_length = 1024*1024*read_length.to_i
92
end
93

  
89 94
s3 = S3.new(s3_config)
90 95

  
91 96
s3.name   = name
......
99 104
cmd = "#{UTILS_PATH}/downloader.sh #{import_source} -"
100 105

  
101 106
Open3.popen3(cmd) do |_, o, _, _|
102
    body = o.read(READ_LENGTH)
107
    body = o.read(read_length)
103 108

  
104 109
    if o.eof?
105 110
        s3.put_object(body)
......
110 115
            s3.upload_part(body)
111 116

  
112 117
            until o.eof?
113
                body = o.read(READ_LENGTH)
118
                body = o.read(read_length)
114 119
                s3.upload_part(body)
115 120
            end
116 121

  

Also available in: Unified diff