Module: TestingBot::Resources::Storage

Included in:
Api
Defined in:
lib/testingbot/resources/storage.rb

Overview

TestingBot Storage endpoints under /storage (mobile app testing).

App URLs target a wildcard route, so they are only stripped of their tb:// scheme (slashes are preserved, not escaped).

Instance Method Summary collapse

Instance Method Details

#delete_uploaded_file(app_url) ⇒ Object



39
40
41
# File 'lib/testingbot/resources/storage.rb', line 39

def delete_uploaded_file(app_url)
  success?(delete("/storage/#{strip_scheme(app_url)}"))
end

#get_uploaded_file(app_url) ⇒ Object



35
36
37
# File 'lib/testingbot/resources/storage.rb', line 35

def get_uploaded_file(app_url)
  get("/storage/#{strip_scheme(app_url)}")
end

#get_uploaded_files(offset = 0, count = 10) ⇒ Object



31
32
33
# File 'lib/testingbot/resources/storage.rb', line 31

def get_uploaded_files(offset = 0, count = 10)
  get("/storage#{query(:offset => offset, :count => count)}")
end

#update_local_file(app_url, file_path) ⇒ Object

Replace the binary stored under an existing app key with a local file.



19
20
21
22
23
24
# File 'lib/testingbot/resources/storage.rb', line 19

def update_local_file(app_url, file_path)
  File.open(file_path, 'rb') do |io|
    @connection.request(:post, "/storage/#{strip_scheme(app_url)}",
                        { :multipart => true, :file => io }, :timeout => 600)
  end
end

#update_remote_file(app_url, url) ⇒ Object

Replace the binary stored under an existing app key with a remote URL.



27
28
29
# File 'lib/testingbot/resources/storage.rb', line 27

def update_remote_file(app_url, url)
  post("/storage/#{strip_scheme(app_url)}", { :url => url })
end

#upload_local_file(file_path) ⇒ Object



8
9
10
11
12
# File 'lib/testingbot/resources/storage.rb', line 8

def upload_local_file(file_path)
  File.open(file_path, 'rb') do |io|
    @connection.request(:post, "/storage", { :multipart => true, :file => io }, :timeout => 600)
  end
end

#upload_remote_file(url) ⇒ Object



14
15
16
# File 'lib/testingbot/resources/storage.rb', line 14

def upload_remote_file(url)
  post("/storage", { :url => url })
end