1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
|
# File 'lib/cnvrg/datafiles.rb', line 1104
def download_file(absolute_path, relative_path, project_home, conflict=false)
res = Cnvrg::API.request(@base_resource + "download_file", 'POST', {absolute_path: absolute_path, relative_path: relative_path})
Cnvrg::CLI.is_response_success(res, false)
if res["result"]
res = res["result"]
return false if res["link"].empty? or res["filename"].empty?
filename = res["filename"]
file_location = absolute_path.gsub(/#{filename}\/?$/, "")
FileUtils.mkdir_p project_home + "/" + file_location
filename += ".conflict" if conflict
File.open("#{project_home}/#{file_location}/#{filename}", "w+") do |file|
file.write open(res["link"]).read
end
else
return false
end
return true
end
|