lib/ayadn/fileops.rb in ayadn-1.7.0 vs lib/ayadn/fileops.rb in ayadn-1.7.1
- old
+ new
@@ -61,9 +61,25 @@
abort(Status.bad_path) unless File.exist?(file)
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)
+ 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)
+ end
+ end
+
private
def get_users(list)
h = {}
list.each {|k,v| h[k] = { username: v[0], name: v[1] }}