303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
# File 'lib/cnvrg/datafiles.rb', line 303
def upload_image(absolute_path, image_name, owner, is_public, is_base, dpkg, libraries, bash, message, commit_id)
file_name = File.basename absolute_path
file_size = File.size(absolute_path).to_f
if is_base
content_type = "application/zip"
else
content_type = "application/gzip"
end
begin
upload_resp = Cnvrg::API.request("users/#{owner}/images/" + "upload_cnvrg", 'POST_FILE', {relative_path: absolute_path,
file_name: file_name,
image_name: image_name,
file_size: file_size,
file_content_type: content_type,
is_public: is_public,
project_slug: @project_slug,
commit_id: commit_id,
dpkg: dpkg,
py2: libraries,
py3: libraries,
bash_history: bash,
commit_message: message,
is_base: is_base})
if Cnvrg::CLI.is_response_success(upload_resp, false)
path = upload_resp["result"]["path"]
s3_res = upload_small_files_s3(path, absolute_path, content_type)
if s3_res
commit_resp = Cnvrg::API.request("users/#{owner}/images/#{upload_resp["result"]["id"]}/" + "commit", 'GET')
if Cnvrg::CLI.is_response_success(commit_resp, false)
return commit_resp["result"]["image"]
else
return false
end
end
end
return false
rescue => e
end
end
|