getSharedFileUrl method
Builds the download URL of a file of a shared activity.
The URL redirects to a short-lived storage URL; the token is the authorization, so no session is needed.
Parameters
shareToken: The Activity.shareToken of the activity.activityFileID: The StoredActivityFile.activityFileID of the file.onComplete: Called with GemError.success and the URL, or an empty string when the token is empty or the id is negative.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? getSharedFileUrl(
String shareToken,
int activityFileID, {
void Function(GemError error, String url)? onComplete,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
progressListener.registerOnCompleteWithData((
int err,
String hint,
Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progressListener.id);
if (err == 0) {
onComplete?.call(GemErrorExtension.fromCode(err), json['result']);
} else {
onComplete?.call(GemErrorExtension.fromCode(err), '');
}
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'getSharedFileUrl',
args: <String, dynamic>{
'shareToken': shareToken,
'activityFileID': activityFileID,
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode, '');
return null;
}
return progressListener;
}