Exemplo n.º 1
0
        /// <summary>
        /// Deletes raw data for the element identified by <paramref name="target"/> and <paramref name="rawDataKey"/>.
        /// </summary>
        /// <param name="target">The <see cref="RawDataTargetEntity"/> object containing the <see cref="RawDataEntity"/> type and the uuid of the raw data that should be deleted.</param>
        /// <param name="rawDataKey">The key of the raw data object which should be deleted.</param>
        /// <param name="cancellationToken">A token to cancel the hronous operation.</param>
        public Task DeleteRawData(RawDataTargetEntity target, int?rawDataKey, CancellationToken cancellationToken = default(CancellationToken))
        {
            StringUuidTools.CheckUuid(target.Entity, target.Uuid);

            var url = rawDataKey.HasValue
                                ? $"rawData/{target.Entity}/{{{target.Uuid}}}/{rawDataKey}"
                                : $"rawData/{target.Entity}/{{{target.Uuid}}}";

            return(_RestClient.Request(RequestBuilder.CreateDelete(url), cancellationToken));
        }
        /// <summary>
        /// Deletes raw data for the element identified by <paramref name="target"/> and <paramref name="rawDataKey"/>.
        /// </summary>
        /// <param name="target">The <see cref="RawDataTargetEntityDto"/> object containing the <see cref="RawDataEntityDto"/> type and the uuid of the raw data that should be deleted.</param>
        /// <param name="rawDataKey">The key of the raw data object which should be deleted.</param>
        /// <param name="cancellationToken">A token to cancel the hronous operation.</param>
        /// <exception cref="ArgumentNullException"><paramref name="target"/> is <see langword="null" />.</exception>
        public Task DeleteRawData(RawDataTargetEntityDto target, int?rawDataKey = null, CancellationToken cancellationToken = default)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            StringUuidTools.CheckUuid(target.Entity, target.Uuid);

            var url = rawDataKey.HasValue
                                ? $"rawData/{target.Entity}/{{{target.Uuid}}}/{rawDataKey}"
                                : $"rawData/{target.Entity}/{{{target.Uuid}}}";

            return(_RestClient.Request(RequestBuilder.CreateDelete(url), cancellationToken));
        }
Exemplo n.º 3
0
        private Task UploadRawData(RawDataInformation info, byte[] data, HttpMethod method, CancellationToken cancellationToken)
        {
            StringUuidTools.CheckUuid(info.Target.Entity, info.Target.Uuid);

            if (string.IsNullOrEmpty(info.FileName))
            {
                throw new ArgumentException("FileName needs to be set.", nameof(info));
            }

            var requestString = info.KeySpecified && info.Key >= 0
                                ? $"rawData/{info.Target.Entity}/{info.Target.Uuid}/{info.Key}"
                                : $"rawData/{info.Target.Entity}/{info.Target.Uuid}";

            var stream = new MemoryStream(data, 0, data.Length, false, true);

            return(_RestClient.Request(RequestBuilder.CreateWithAttachment(method, requestString, stream, info.MimeType, info.Size, info.MD5, info.FileName), cancellationToken));
        }