startFileDataUpload method
Future<Response<FileUploadURL> >
startFileDataUpload({
- required String fileId,
- required int versionId,
- required String fileType,
- @Deprecated('partNumber is deprecated') int? partNumber,
- CancelToken? cancelToken,
- Map<
String, dynamic> ? headers, - Map<
String, dynamic> ? extra, - ValidateStatus? validateStatus,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
Start FileData Upload Starts an upload of a specific FilePart. This endpoint will return an AWS URL which you can PUT data to. You need to call this and receive a new AWS API URL for each `partNumber`. Please see AWS's REST documentation on "PUT Object to S3" on how to upload. Once all parts has been uploaded, proceed to `/finish` endpoint. Note: `nextPartNumber` seems like it is always ignored. Despite it returning 0, first partNumber is always 1.
Parameters:
fileId
- Must be a valid file ID.versionId
- Version ID of the asset.fileType
- Type of file.partNumber
- The part number to start uploading. If not provided, the first part will be started.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 FileUploadURL as data
Throws DioException
if API call or serialization fails
Implementation
Future<Response<FileUploadURL>> startFileDataUpload({
required String fileId,
required int versionId,
required String fileType,
@Deprecated('partNumber is deprecated') int? partNumber,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final _path = r'/file/{fileId}/{versionId}/{fileType}/start'
.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,
},
validateStatus: validateStatus,
);
final _queryParameters = <String, dynamic>{
if (partNumber != null) r'partNumber': partNumber,
};
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
FileUploadURL? _responseData;
try {
final rawData = _response.data;
_responseData = rawData == null
? null
: deserialize<FileUploadURL, FileUploadURL>(rawData, 'FileUploadURL',
growable: true);
} catch (error, stackTrace) {
throw DioException(
requestOptions: _response.requestOptions,
response: _response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<FileUploadURL>(
data: _responseData,
headers: _response.headers,
isRedirect: _response.isRedirect,
requestOptions: _response.requestOptions,
redirects: _response.redirects,
statusCode: _response.statusCode,
statusMessage: _response.statusMessage,
extra: _response.extra,
);
}