getFileUploadURL method

Future<GetFileUploadURLResponse> getFileUploadURL({
  1. required String assignmentId,
  2. required String questionIdentifier,
})

The GetFileUploadURL operation generates and returns a temporary URL. You use the temporary URL to retrieve a file uploaded by a Worker as an answer to a FileUploadAnswer question for a HIT. The temporary URL is generated the instant the GetFileUploadURL operation is called, and is valid for 60 seconds. You can get a temporary file upload URL any time until the HIT is disposed. After the HIT is disposed, any uploaded files are deleted, and cannot be retrieved. Pending Deprecation on December 12, 2017. The Answer Specification structure will no longer support the FileUploadAnswer element to be used for the QuestionForm data structure. Instead, we recommend that Requesters who want to create HITs asking Workers to upload files to use Amazon S3.

May throw ServiceFault. May throw RequestError.

Parameter assignmentId : The ID of the assignment that contains the question with a FileUploadAnswer.

Parameter questionIdentifier : The identifier of the question with a FileUploadAnswer, as specified in the QuestionForm of the HIT.

Implementation

Future<GetFileUploadURLResponse> getFileUploadURL({
  required String assignmentId,
  required String questionIdentifier,
}) async {
  ArgumentError.checkNotNull(assignmentId, 'assignmentId');
  _s.validateStringLength(
    'assignmentId',
    assignmentId,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(questionIdentifier, 'questionIdentifier');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'MTurkRequesterServiceV20170117.GetFileUploadURL'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AssignmentId': assignmentId,
      'QuestionIdentifier': questionIdentifier,
    },
  );

  return GetFileUploadURLResponse.fromJson(jsonResponse.body);
}