finishFileDataUpload method
Future<Response<File> >
finishFileDataUpload({
- required String fileId,
- required int versionId,
- required String fileType,
- FinishFileDataUploadRequest? finishFileDataUploadRequest,
- CancelToken? cancelToken,
- Map<
String, dynamic> ? headers, - Map<
String, dynamic> ? extra, - ValidateStatus? validateStatus,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
Finish FileData Upload Finish an upload of a FileData. This will mark it as "complete". After uploading the `file` for Avatars and Worlds you then have to upload a `signature` file.
Parameters:
fileId
- Must be a valid file ID.versionId
- Version ID of the asset.fileType
- Type of file.finishFileDataUploadRequest
- Please see documentation on ETag's: https://teppen.io/2018/06/23/aws_s3_etags/ ETag's should NOT be present when uploading asignature
.cancelToken
- ACancelToken
that can be used to cancel the operationheaders
- Can be used to add additional headers to the requestextras
- Can be used to add flags to the requestvalidateStatus
- AValidateStatus
callback that can be used to determine request success based on the HTTP status of the responseonSendProgress
- AProgressCallback
that can be used to get the send progressonReceiveProgress
- AProgressCallback
that can be used to get the receive progress
Returns a Future containing a Response
with a File as data
Throws DioException
if API call or serialization fails
Implementation
Future<Response<File>> finishFileDataUpload({
required String fileId,
required int versionId,
required String fileType,
FinishFileDataUploadRequest? finishFileDataUploadRequest,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/file/{fileId}/{versionId}/{fileType}/finish'
.replaceAll('{' r'fileId' '}', fileId.toString())
.replaceAll('{' r'versionId' '}', versionId.toString())
.replaceAll('{' r'fileType' '}', fileType.toString());
final _options = Options(
method: r'PUT',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'apiKey',
'name': 'authCookie',
'keyName': 'auth',
'where': '',
},
],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
dynamic _bodyData;
try {
_bodyData = jsonEncode(finishFileDataUploadRequest);
} catch (error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
_path,
),
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
final _response = await _dio.request<Object>(
_path,
data: _bodyData,
options: _options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
File? _responseData;
try {
final rawData = _response.data;
_responseData = rawData == null
? null
: deserialize<File, File>(rawData, 'File', growable: true);
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<File>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}