uploadVideo method

Future<XRPCResponse<JobStatus>> uploadVideo(
  1. Uint8List bytes, {
  2. Map<String, String>? $headers,
})

Implementation

Future<core.XRPCResponse<JobStatus>> uploadVideo(
  final Uint8List bytes, {
  Map<String, String>? $headers,
}) async {
  final auth = await _ctx.atproto.server.getServiceAuth(
    aud: 'did:web:${_ctx.service}',
    lxm: comAtprotoRepoUploadBlob,
    exp: DateTime.now().add(Duration(minutes: 30)).millisecondsSinceEpoch ~/
        1000,
  );

  final mimeType = _detectVideoMimeType(bytes);

  return await _ctx.post(
    service: _videoService,
    ns.appBskyVideoUploadVideo,
    headers: {
      'Authorization': 'Bearer ${auth.data.token}',
      'Content-Type': mimeType,
      'Content-Length': bytes.lengthInBytes.toString(),
      ...?$headers,
    },
    parameters: {
      'did': _ctx.atproto.session!.did,
      'name': '${nanoid(12)}.${_getVideoExtension(mimeType)}',
    },
    body: bytes,
    to: JobStatus.fromJson,
  );
}