21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/cnvrg/files.rb', line 21
def upload_file(absolute_path, relative_path, commit_sha1)
file_name = File.basename relative_path
file_size = File.size(absolute_path).to_f
mime_type = MimeMagic.by_path(absolute_path)
content_type = !(mime_type.nil? or mime_type.text?) ? mime_type.type : "text/plain"
sha1 = OpenSSL::Digest::SHA1.file(absolute_path).hexdigest
upload_resp = Cnvrg::API.request(@base_resource + "upload_file", 'POST_FILE', {absolute_path: absolute_path, relative_path: relative_path,
commit_sha1: commit_sha1, file_name: file_name,
file_size: file_size, file_content_type: content_type, sha1: sha1,
new_version:true,only_large:true})
if Cnvrg::CLI.is_response_success(upload_resp, false)
path = upload_resp["result"]["path"]
s3_res = upload_large_files_s3(upload_resp, absolute_path)
return s3_res
end
return false
end
|