Module: Strava::Api::Endpoints::Uploads

Included in:
Client
Defined in:
lib/strava/api/endpoints/uploads.rb

Overview

API endpoints for Strava uploads.

Uploads allow you to create activities by uploading activity files in various formats such as FIT, TCX, and GPX. After uploading, the file is processed asynchronously and you can check the upload status to determine when the activity has been created.

Instance Method Summary collapse

Instance Method Details

#create_upload(options = {}) ⇒ Object

Uploads a new data file to create an activity from.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (File)

    The uploaded file.

  • :name (String)

    The desired name of the resulting activity.

  • :description (String)

    The desired description of the resulting activity.

  • :trainer (Boolean)

    Whether the resulting activity should be marked as having been performed on a trainer.

  • :commute (Boolean)

    Whether the resulting activity should be tagged as a commute.

  • :data_type (String)

    The format of the uploaded file.

  • :external_id (String)

    The desired external identifier of the resulting activity.



35
36
37
# File 'lib/strava/api/endpoints/uploads.rb', line 35

def create_upload(options = {})
  Strava::Models::Upload.new(post('uploads', options))
end

#upload(id_or_options, options = {}) ⇒ Object

Returns an upload for a given identifier.

Parameters:

  • id_or_options (String, Integer, Hash)

    Either an upload ID or a hash of options including :id

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

    Additional options (if first parameter is an ID)



45
46
47
48
# File 'lib/strava/api/endpoints/uploads.rb', line 45

def upload(id_or_options, options = {})
  id, options = parse_args(id_or_options, options)
  Strava::Models::Upload.new(get("uploads/#{id}", options))
end