createShareRaw method
- @experimental
Create a share.
This method and the response it returns is experimental. The API might change without a major version bump.
Returns a Future containing a DynamiteRawResponse with the raw HttpClientResponse and serialization helpers.
Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
pathPath of the share.permissionsPermissions for the share.shareTypeType of the share. Defaults to-1.shareWithThe entity this should be shared with.publicUploadIf public uploading is allowed. Defaults tofalse.passwordPassword for the share. Defaults to''.sendPasswordByTalkSend the password for the share over Talk.expireDateExpiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used. Defaults to''.noteNote for the share. Defaults to''.labelLabel for the share (only used in link and email). Defaults to''.attributesAdditional attributes for the share.oCSAPIRequestRequired to be true for the API request to pass. Defaults totrue.
Status codes:
- 200: Share created
- 400: Unknown share type
- 403: Creating the share is not allowed
- 404: Creating the share failed
See:
- createShare for an operation that returns a
DynamiteResponsewith a stable API.
Implementation
@_i4.experimental
_i1.DynamiteRawResponse<ShareapiCreateShareResponseApplicationJson, void> createShareRaw({
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, dynamic>{};
final _headers = <String, String>{'Accept': 'application/json'};
// coverage:ignore-start
final authentication = _rootClient.authentications?.firstWhereOrNull(
(auth) => switch (auth) {
_i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
_ => false,
},
);
if (authentication != null) {
_headers.addAll(
authentication.headers,
);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth');
}
// coverage:ignore-end
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;
var $oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
$oCSAPIRequest ??= true;
_headers['OCS-APIRequest'] = const _i2.HeaderEncoder().convert($oCSAPIRequest);
final _path = _i3.UriTemplate(
'/ocs/v2.php/apps/files_sharing/api/v1/shares{?path*,permissions*,shareType*,shareWith*,publicUpload*,password*,sendPasswordByTalk*,expireDate*,note*,label*,attributes*}',
).expand(_parameters);
return _i1.DynamiteRawResponse<ShareapiCreateShareResponseApplicationJson, void>(
response: _rootClient.executeRequest(
'post',
_path,
headers: _headers,
validStatuses: const {200},
),
bodyType: const FullType(ShareapiCreateShareResponseApplicationJson),
headersType: null,
serializers: _$jsonSerializers,
);
}