Class: MediaWiktory::Wikipedia::Actions::Upload

Inherits:
Post
  • Object
show all
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

Methods inherited from Post

#perform

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

#asyncself

Make potentially large file operations asynchronous when possible.

Returns:

  • (self)


152
153
154
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 152

def async()
  merge(async: 'true')
end

#checkstatusself

Only fetch the upload status for the given file key.

Returns:

  • (self)


159
160
161
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 159

def checkstatus()
  merge(checkstatus: 'true')
end

#chunk(value) ⇒ self

Chunk contents.

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (Integer)

Returns:

  • (self)


129
130
131
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 129

def filesize(value)
  merge(filesize: value.to_s)
end

#ignorewarningsself

Ignore any warnings.

Returns:

  • (self)


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.

Parameters:

  • value (Integer)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


114
115
116
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 114

def sessionkey(value)
  merge(sessionkey: value.to_s)
end

#stashself

If set, the server will stash the file temporarily instead of adding it to the repository.

Returns:

  • (self)


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.

Parameters:

  • values (Array<String>)

    Allowed values: "ProveIt edit", "WPCleaner", "huggle", "large plot addition".

Returns:

  • (self)


42
43
44
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 42

def tags(*values)
  values.inject(self) { |res, val| res._tags(val) or fail ArgumentError, "Unknown value for tags: #{val}" }
end

#text(value) ⇒ self

Initial page text for new files.

Parameters:

  • value (String)

Returns:

  • (self)


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

Parameters:

  • value (String)

Returns:

  • (self)


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.

Parameters:

  • value (String)

Returns:

  • (self)


98
99
100
# File 'lib/mediawiktory/wikipedia/actions/upload.rb', line 98

def url(value)
  merge(url: value.to_s)
end

#watchself

Watch the page.

Returns:

  • (self)


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.

Parameters:

  • value (String)

    One of "watch", "preferences", "nochange".

Returns:

  • (self)


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