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:
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 tofalse
.password
Password for the share. Defaults to''
.sendPasswordByTalk
Send the password for the share over Talk.expireDate
Expiry date of the share. 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 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 DynamiteResponse with a stable API.
Implementation
@experimental
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) {
DynamiteHttpBearerAuthentication() || 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 dynamite_utils.HeaderEncoder().convert($oCSAPIRequest);
final _path = UriTemplate(
'/ocs/v2.php/apps/files_sharing/api/v1/shares{?path*,permissions*,shareType*,shareWith*,publicUpload*,password*,sendPasswordByTalk*,expireDate*,note*,label*,attributes*}',
).expand(_parameters);
return DynamiteRawResponse<ShareapiCreateShareResponseApplicationJson, void>(
response: _rootClient.executeRequest(
'post',
_path,
_headers,
null,
const {200},
),
bodyType: const FullType(ShareapiCreateShareResponseApplicationJson),
headersType: null,
serializers: jsonSerializers,
);
}