$createShare_Request method

  1. @experimental
Request $createShare_Request({
  1. String? path,
  2. int? permissions,
  3. int? shareType,
  4. String? shareWith,
  5. String? publicUpload,
  6. String? password,
  7. String? sendPasswordByTalk,
  8. String? expireDate,
  9. String? note,
  10. String? label,
  11. String? attributes,
  12. bool? oCSAPIRequest,
})

Create a share.

Returns a DynamiteRequest backing the createShare operation. Throws a DynamiteApiException if the API call does not return an expected status code.

Parameters:

  • path Path of the share.
  • permissions Permissions for the share.
  • shareType Type of the share. Defaults to -1.
  • shareWith The entity this should be shared with.
  • publicUpload If public uploading is allowed. Defaults to "false".
  • password Password for the share. Defaults to "".
  • sendPasswordByTalk Send the password for the share over Talk.
  • expireDate Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used. Defaults to "".
  • note Note for the share. Defaults to "".
  • label Label for the share (only used in link and email). Defaults to "".
  • attributes Additional attributes for the share.
  • oCSAPIRequest Required to be true for the API request to pass. Defaults to true.

Status codes:

  • 200: Share created
  • 400: Unknown share type
  • 403: Creating the share is not allowed
  • 404: Creating the share failed

See:

Implementation

@_i2.experimental
_i3.Request $createShare_Request({
  String? path,
  int? permissions,
  int? shareType,
  String? shareWith,
  String? publicUpload,
  String? password,
  String? sendPasswordByTalk,
  String? expireDate,
  String? note,
  String? label,
  String? attributes,
  bool? oCSAPIRequest,
}) {
  final _parameters = <String, Object?>{};
  final $path = _$jsonSerializers.serialize(path, specifiedType: const FullType(String));
  _parameters['path'] = $path;

  final $permissions = _$jsonSerializers.serialize(permissions, specifiedType: const FullType(int));
  _parameters['permissions'] = $permissions;

  var $shareType = _$jsonSerializers.serialize(shareType, specifiedType: const FullType(int));
  $shareType ??= -1;
  _parameters['shareType'] = $shareType;

  final $shareWith = _$jsonSerializers.serialize(shareWith, specifiedType: const FullType(String));
  _parameters['shareWith'] = $shareWith;

  var $publicUpload = _$jsonSerializers.serialize(publicUpload, specifiedType: const FullType(String));
  $publicUpload ??= 'false';
  _parameters['publicUpload'] = $publicUpload;

  var $password = _$jsonSerializers.serialize(password, specifiedType: const FullType(String));
  $password ??= '';
  _parameters['password'] = $password;

  final $sendPasswordByTalk = _$jsonSerializers.serialize(sendPasswordByTalk, specifiedType: const FullType(String));
  _parameters['sendPasswordByTalk'] = $sendPasswordByTalk;

  var $expireDate = _$jsonSerializers.serialize(expireDate, specifiedType: const FullType(String));
  $expireDate ??= '';
  _parameters['expireDate'] = $expireDate;

  var $note = _$jsonSerializers.serialize(note, specifiedType: const FullType(String));
  $note ??= '';
  _parameters['note'] = $note;

  var $label = _$jsonSerializers.serialize(label, specifiedType: const FullType(String));
  $label ??= '';
  _parameters['label'] = $label;

  final $attributes = _$jsonSerializers.serialize(attributes, specifiedType: const FullType(String));
  _parameters['attributes'] = $attributes;

  final _path = _i5.UriTemplate(
    '/ocs/v2.php/apps/files_sharing/api/v1/shares{?path*,permissions*,shareType*,shareWith*,publicUpload*,password*,sendPasswordByTalk*,expireDate*,note*,label*,attributes*}',
  ).expand(_parameters);
  final _uri = Uri.parse('${_rootClient.baseURL}$_path');
  final _request = _i3.Request('post', _uri);
  _request.headers['Accept'] = 'application/json';
// coverage:ignore-start
  final authentication = _rootClient.authentications?.firstWhereOrNull(
    (auth) => switch (auth) {
      _i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
      _ => false,
    },
  );

  if (authentication != null) {
    _request.headers.addAll(
      authentication.headers,
    );
  } else {
    throw Exception('Missing authentication for bearer_auth or basic_auth');
  }

// coverage:ignore-end
  var $oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
  $oCSAPIRequest ??= true;
  _request.headers['OCS-APIRequest'] = const _i4.HeaderEncoder().convert($oCSAPIRequest);

  return _request;
}