Class: Nylas::Attachments
- Includes:
- Nylas::ApiOperations::Get
- Defined in:
- lib/nylas/resources/attachments.rb
Overview
Nylas Attachment API
Instance Method Summary collapse
-
#download(identifier:, attachment_id:, query_params:) {|chunk| ... } ⇒ nil, String
Download the attachment data.
-
#download_bytes(identifier:, attachment_id:, query_params:) ⇒ nil, Array(Integer)
Download the attachment as a byte array.
-
#find(identifier:, attachment_id:, query_params:) ⇒ Array(Hash, String)
Return metadata of an attachment.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Nylas::Resource
Instance Method Details
#download(identifier:, attachment_id:, query_params:) {|chunk| ... } ⇒ nil, String
Download the attachment data.
This method supports streaming the download by passing a block, which will be called with each chunk of the response body as it is read. If no block is given, the entire response will be read into memory and returned (not recommended for large files).
37 38 39 40 41 42 43 44 45 |
# File 'lib/nylas/resources/attachments.rb', line 37 def download(identifier:, attachment_id:, query_params:, &block) download_request( path: "#{api_uri}/v3/grants/#{identifier}/attachments/#{}/download", query: query_params, api_key: api_key, timeout: timeout, &block ) end |
#download_bytes(identifier:, attachment_id:, query_params:) ⇒ nil, Array(Integer)
Download the attachment as a byte array.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nylas/resources/attachments.rb', line 54 def download_bytes(identifier:, attachment_id:, query_params:) data = download_request( path: "#{api_uri}/v3/grants/#{identifier}/attachments/#{}/download", query: query_params, api_key: api_key, timeout: timeout ) data&.bytes end |
#find(identifier:, attachment_id:, query_params:) ⇒ Array(Hash, String)
Return metadata of an attachment.
17 18 19 20 21 22 |
# File 'lib/nylas/resources/attachments.rb', line 17 def find(identifier:, attachment_id:, query_params:) get( path: "#{api_uri}/v3/grants/#{identifier}/attachments/#{}", query_params: query_params ) end |