Module: Parse::API::Files

Included in:
Client
Defined in:
lib/parse/api/files.rb

Overview

Defines the Parse Files interface for the Parse REST API

Instance Method Summary collapse

Instance Method Details

#create_file(fileName, data = {}, content_type = nil) ⇒ Parse::Response

Upload and create a Parse file.

Parameters:

  • fileName (String)

    the basename of the file.

  • data (Hash) (defaults to: {})

    the data related to this file.

  • content_type (String) (defaults to: nil)

    the mime-type of the file.

Returns:


20
21
22
23
24
25
26
# File 'lib/parse/api/files.rb', line 20

def create_file(fileName, data = {}, content_type = nil)
  headers = {}
  headers.merge!( { Parse::Protocol::CONTENT_TYPE => content_type.to_s } ) if content_type.present?
  response = request :post, "#{FILES_PATH}/#{fileName}", body: data, headers: headers
  response.parse_class = Parse::Model::TYPE_FILE
  response
end