Module: JSS::Uploadable::ClassMethods
- Defined in:
- lib/jss/api_object/uploadable.rb
Overview
Class/Module Methods
Instance Method Summary collapse
-
#upload(ident, type, local_file, force_ipa_upload: false, api: JSS.api) ⇒ Boolean
Upload a file to the JSS to be stored with an item of the class mixing in the Uploadable module.
Instance Method Details
#upload(ident, type, local_file, force_ipa_upload: false, api: JSS.api) ⇒ Boolean
Upload a file to the JSS to be stored with an item of the class mixing in the Uploadable module.
This class method does not require fetching a Ruby instance first, but the matching instance method will work for a specific instance if it's already been fetched.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/jss/api_object/uploadable.rb', line 126 def upload(ident, type, local_file, force_ipa_upload: false, api: JSS.api) id = valid_id ident, :refresh, api: api raise "No #{self::RSRC_OBJECT_KEY} matching '#{ident}'" unless id # the type has to be defined in the class including this module. raise JSS::InvalidDataError, "#{self::RSRC_LIST_KEY} only take uploads of type: :#{self::UPLOAD_TYPES.keys.join(', :')}." \ unless self::UPLOAD_TYPES.key? type # figure out the resource after the UPLOAD_RSRC_PREFIX upload_rsrc = "#{UPLOAD_RSRC_PREFIX}/#{self::UPLOAD_TYPES[type]}/id/#{id}" upload_rsrc << "?#{FORCE_IPA_UPLOAD_PARAM}=true" if self::UPLOAD_TYPES[type] == :mobiledeviceapplicationsipa && force_ipa_upload api.upload upload_rsrc, local_file end |