Class: MediaWiktory::Wikipedia::Actions::Upload
- Defined in:
- lib/mediawiktory/wikipedia/actions/upload.rb
Overview
Upload a file, or get the status of pending uploads.
Usage:
api.upload.filename(value).perform # returns string with raw output
# or
api.upload.filename(value).response # returns output parsed and wrapped into Response object
See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.
All action's parameters are documented as its public methods, see below.
Instance Method Summary collapse
-
#async ⇒ self
Make potentially large file operations asynchronous when possible.
-
#checkstatus ⇒ self
Only fetch the upload status for the given file key.
-
#chunk(value) ⇒ self
Chunk contents.
-
#comment(value) ⇒ self
Upload comment.
-
#file(value) ⇒ self
File contents.
-
#filekey(value) ⇒ self
Key that identifies a previous upload that was stashed temporarily.
-
#filename(value) ⇒ self
Target filename.
-
#filesize(value) ⇒ self
Filesize of entire upload.
-
#ignorewarnings ⇒ self
Ignore any warnings.
-
#offset(value) ⇒ self
Offset of chunk in bytes.
-
#sessionkey(value) ⇒ self
Same as filekey, maintained for backward compatibility.
-
#stash ⇒ self
If set, the server will stash the file temporarily instead of adding it to the repository.
-
#tags(*values) ⇒ self
Change tags to apply to the upload log entry and file page revision.
-
#text(value) ⇒ self
Initial page text for new files.
-
#token(value) ⇒ self
A "csrf" token retrieved from action=query&meta=tokens.
-
#url(value) ⇒ self
URL to fetch the file from.
-
#watch ⇒ self
Watch the page.
-
#watchlist(value) ⇒ self
Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.
Methods inherited from Post
Methods inherited from Base
#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url
Methods included from GlobalParams
#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang
Instance Method Details
#async ⇒ self
Make potentially large file operations asynchronous when possible.
152 153 154 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 152 def async() merge(async: 'true') end |
#checkstatus ⇒ self
Only fetch the upload status for the given file key.
159 160 161 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 159 def checkstatus() merge(checkstatus: 'true') end |
#chunk(value) ⇒ self
Chunk contents.
145 146 147 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 145 def chunk(value) merge(chunk: value.to_s) end |
#comment(value) ⇒ self
Upload comment. Also used as the initial page text for new files if text is not specified.
34 35 36 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 34 def comment(value) merge(comment: value.to_s) end |
#file(value) ⇒ self
File contents.
90 91 92 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 90 def file(value) merge(file: value.to_s) end |
#filekey(value) ⇒ self
Key that identifies a previous upload that was stashed temporarily.
106 107 108 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 106 def filekey(value) merge(filekey: value.to_s) end |
#filename(value) ⇒ self
Target filename.
26 27 28 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 26 def filename(value) merge(filename: value.to_s) end |
#filesize(value) ⇒ self
Filesize of entire upload.
129 130 131 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 129 def filesize(value) merge(filesize: value.to_s) end |
#ignorewarnings ⇒ self
Ignore any warnings.
82 83 84 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 82 def ignorewarnings() merge(ignorewarnings: 'true') end |
#offset(value) ⇒ self
Offset of chunk in bytes.
137 138 139 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 137 def offset(value) merge(offset: value.to_s) end |
#sessionkey(value) ⇒ self
Same as filekey, maintained for backward compatibility.
114 115 116 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 114 def sessionkey(value) merge(sessionkey: value.to_s) end |
#stash ⇒ self
If set, the server will stash the file temporarily instead of adding it to the repository.
121 122 123 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 121 def stash() merge(stash: 'true') end |
#tags(*values) ⇒ self
Change tags to apply to the upload log entry and file page revision.
42 43 44 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 42 def (*values) values.inject(self) { |res, val| res.(val) or fail ArgumentError, "Unknown value for tags: #{val}" } end |
#text(value) ⇒ self
Initial page text for new files.
55 56 57 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 55 def text(value) merge(text: value.to_s) end |
#token(value) ⇒ self
A "csrf" token retrieved from action=query&meta=tokens
167 168 169 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 167 def token(value) merge(token: value.to_s) end |
#url(value) ⇒ self
URL to fetch the file from.
98 99 100 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 98 def url(value) merge(url: value.to_s) end |
#watch ⇒ self
Watch the page.
62 63 64 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 62 def watch() merge(watch: 'true') end |
#watchlist(value) ⇒ self
Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.
70 71 72 |
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 70 def watchlist(value) _watchlist(value) or fail ArgumentError, "Unknown value for watchlist: #{value}" end |