Module: Asana::Resources::AttachmentUploading Private
- Included in:
- Task
- Defined in:
- lib/asana/resource_includes/attachment_uploading.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Mixin to add the ability to upload an attachment to a specific Asana resource (a Task, really).
Instance Method Summary collapse
-
#attach(filename: required('filename'), mime: required('mime'), options: {}, **data) ⇒ Object
private
Uploads a new attachment to the resource.
Instance Method Details
#attach(filename: required('filename'), mime: required('mime'), options: {}, **data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Uploads a new attachment to the resource.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/asana/resource_includes/attachment_uploading.rb', line 15 def attach(filename: required('filename'), mime: required('mime'), options: {}, **data) path = File.(filename) unless File.exist?(path) fail ArgumentError, "file #{filename} doesn't exist" end upload = Faraday::UploadIO.new(path, mime) response = client.post("/#{self.class.plural_name}/#{id}/attachments", body: data, upload: upload, options: ) Attachment.new(parse(response).first, client: client) end |