Class: Wechat::Media
- Inherits:
-
DataObject
- Object
- DataObject
- Wechat::Media
- Defined in:
- lib/wechat/data_objects/media.rb
Overview
Methods for transfering media files
> admin.wechat.com/wiki/index.php?title=Transferring_Multimedia_Files
Class Method Summary collapse
-
.download(media_id) ⇒ String
Path to downloaded file.
- .upload(type, path) ⇒ Object
Methods inherited from DataObject
get, parameterize_params, post, #request
Class Method Details
.download(media_id) ⇒ String
Returns path to downloaded file.
41 42 43 44 |
# File 'lib/wechat/data_objects/media.rb', line 41 def download(media_id) get "media/get", {media_id: media_id} end |
.upload(type, path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wechat/data_objects/media.rb', line 19 def upload(type, path) if path.include?'http' # We create a local representation of the remote resource # local_resource = LocalResource.new URI.parse(path) local_resource = LocalResource.new(URI.parse(path)) # We have a copy of the remote file for processing local_copy_of_remote_file = local_resource.file path = local_copy_of_remote_file.path end file = File.new(path,'rb') post "media/upload", {media: file, type: type} end |