createAssembly method
Creates the Assembly using the options specified.
onProgress
returns the progress of the file upload
onComplete
will call when the file is uploaded and the assembly is processing
Implementation
Future<TransloaditResponse> createAssembly(
{Function(double)? onProgress, Function()? onComplete}) async {
final data = super.options;
final extraData = {
"tus_num_expected_upload_files": files.length.toString()
};
TransloaditResponse response = await client.request.httpPost(
service: client.service,
assemblyPath: "/assemblies",
params: data,
extraParams: extraData);
if (response.data.containsKey("assembly_ssl_url")) {
await tusUpload(
response.data["assembly_ssl_url"],
response.data["tus_url"],
onProgress: (progress) {
if (onProgress != null) {
onProgress(progress);
}
},
onComplete: () {
if (onComplete != null) {
onComplete();
}
},
);
}
while (!isAssemblyFinished(response)) {
final url = response.data["assembly_ssl_url"].toString();
response = await client.getAssembly(assemblyURL: url);
}
return response;
}