private Task UploadRawData(RawDataInformation info, Stream data, HttpMethod method, CancellationToken cancellationToken) { if (info.Target.Entity == RawDataEntity.Value && !StringUuidTools.IsStringUuidPair(info.Target.Uuid)) { throw new ArgumentOutOfRangeException("info", "The uuid string for uploading raw data for measurement value needs 2 uuids in the format: {measurementUuid}|{characteristicUuid}"); } if (String.IsNullOrEmpty(info.FileName)) { throw new ArgumentException("FileName needs to be set.", "info"); } var requestString = info.Key >= 0 ? string.Format("rawData/{0}/{1}/{2}", info.Target.Entity, info.Target.Uuid, info.Key) : string.Format("rawData/{0}/{1}", info.Target.Entity, info.Target.Uuid); if (method.Equals(HttpMethod.Post)) { return(Post(requestString, data, cancellationToken, info.Size, info.MimeType, info.MD5, info.FileName)); } if (method.Equals(HttpMethod.Put)) { return(Put(requestString, data, cancellationToken, info.Size, info.MimeType, info.MD5, info.FileName)); } throw new ArgumentOutOfRangeException("method"); }
/// <summary> /// Deletes raw data for the element identified by <paramref name="info"/>. /// </summary> /// <param name="info">The <see cref="RawDataInformation"/> object containing the <see cref="RawDataEntity"/> type, the uuid and the key of the raw data that should be deleted.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task DeleteRawData(RawDataInformation info, CancellationToken cancellationToken = default(CancellationToken)) { if (info.Target.Entity == RawDataEntity.Value && !StringUuidTools.IsStringUuidPair(info.Target.Uuid)) { throw new ArgumentOutOfRangeException("info", "The uuid string for uploading raw data for measurement value needs two uuids in the format: {measurementUuid}|{characteristicUuid}"); } var url = info.Key >= 0 ? string.Format("rawData/{0}/{{{1}}}/{2}", info.Target.Entity, info.Target.Uuid, info.Key) : string.Format("rawData/{0}/{{{1}}}", info.Target.Entity, info.Target.Uuid); return(Delete(url, cancellationToken)); }