lib/ayadn/fileops.rb in ayadn-1.8.2 vs lib/ayadn/fileops.rb in ayadn-2.0
- old
+ new
@@ -32,14 +32,10 @@
def self.download_url(name, url)
file = CNX.get_response_from(url)
File.write(Settings.config[:paths][:downloads] + "/#{name}", file)
end
- def self.old_ayadn?
- Dir.exist?(Dir.home + "/ayadn/data")
- end
-
def self.upload_files files
files.map do |file|
puts "\n#{file}\n\n"
JSON.load(self.upload(file, Settings.user_token))
end
@@ -54,33 +50,39 @@
`curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/gif" -F 'public=true' -X POST`
else #jpg or jpeg or JPG or JPEG, automatically recognized as such
`curl -k -H 'Authorization: BEARER #{token}' https://api.app.net/files -F 'type=com.ayadn.files' -F "content=@#{file}" -F 'public=true' -X POST`
end
rescue Errno::ENOENT
- abort(Status.no_curl)
+ Status.new.no_curl
+ exit
end
end
def self.make_paths(files_array)
files_array.map do |file|
- abort(Status.bad_path) unless File.exist?(file)
+ unless File.exist?(file)
+ Status.new.bad_path
+ exit
+ end
File.absolute_path(file)
end
end
def self.upload_avatar file
begin
`curl -X POST -H "Authorization: Bearer #{Settings.user_token}" -F "avatar=@#{file}" #{Endpoints.new.avatar}`
rescue Errno::ENOENT
- abort(Status.no_curl)
+ Status.new.no_curl
+ exit
end
end
def self.upload_cover file
begin
`curl -X POST -H "Authorization: Bearer #{Settings.user_token}" -F "cover=@#{file}" #{Endpoints.new.cover}`
rescue Errno::ENOENT
- abort(Status.no_curl)
+ Status.new.no_curl
+ exit
end
end
def self.get_users(list)
h = {}