GetFileUpload: Get Files Uploaded by Workers

Description Usage Arguments Details Value Author(s) References Examples

Description

Get the URL for a file uploaded by a worker as part of a QuestionForm HIT, or download the file(s) directly to the working directory.

Usage

1
2
3
4
GetFileUpload(assignment, questionIdentifier, download = FALSE, 
              open.file.in.browser = FALSE, 
              verbose = getOption('MTurkR.verbose', TRUE), 
              ...)

Arguments

assignment

A character string containing an AssignmentId, or a vector of character strings each containing an AssignmentId.

questionIdentifier

A question identifier for a file upload question, as specified in the question parameter of CreateHIT or in the placeholder of a HIT template created in the RUI.

download

A logical specifying whether the file(s) should be downloaded and saved in the working directory. Default is FALSE.

open.file.in.browser

A logical specifying whether the file should be opened in the user's default web browser.

verbose

Optionally print the results of the API request to the standard output. Default is taken from getOption('MTurkR.verbose', TRUE).

...

Additional arguments passed to request.

Details

Note that a FileUploadURL is only valid for 60 seconds (per MTurk documentation), so URLs should either be retrieved one at a time or files should be automatically downloaded to the working directory with the download = TRUE. If browser = TRUE, request is executed in the user's default web browser, whereas if open.file.in.browser = TRUE, the request is executed in R and the file itself is opened in the browser.

If downloaded, files are saved in the local directory with names of the form “QuestionIdentifer_AssignmentId_UploadedFileName.UploadedFileExtension”. One may want to use setwd to move to an appropriate directory before initiating this operation with download = TRUE.

geturls() is an alias.

Value

A data frame containing the AssignmentId, questionIdenifier, temporary file URL, and an indicator of whether each request was valid.

Author(s)

Thomas J. Leeper

References

API Reference

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
a <- GenerateExternalQuestion("http://www.example.com/","400")
hit1 <- 
CreateHIT(title = "Upload a file",
          description = "Upload a file",
          reward = ".10",
          duration = seconds(days=1),
          keywords = "file, upload",
          question = a$string)
ExpireHIT(hit1$HITId)
a <- GetAssignments(hit = hit1$HITId)
f <- GetFileUpload(a, "dictation", download = TRUE)

# cleanup
DisposeHIT(hit1$HITId)

## End(Not run)

MTurkR documentation built on May 29, 2017, 11:09 p.m.