Exemplo n.º 1
0
        public async Task <MetadataResponse> GetFileMetadataAsync(string fileId)
        {
            if (string.IsNullOrEmpty(fileId))
            {
                throw new ArgumentException(errorMessages.FILE_ID_MISSING);
            }
            Uri apiEndpoint = new Uri(Utils.GetFileApi() + "/" + fileId + "/metadata");
            HttpResponseMessage response = await Utils.GetAsync(apiEndpoint, (string)options["privateKey"]).ConfigureAwait(false);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            MetadataResponse resp = JsonConvert.DeserializeObject <MetadataResponse>(responseContent);

            resp.StatusCode = response.StatusCode.ToString();
            return(resp);
        }
Exemplo n.º 2
0
        public MetadataResponse GetFileMetadata(string fileId)
        {
            if (string.IsNullOrEmpty(fileId))
            {
                throw new ArgumentException(errorMessages.FILE_ID_MISSING);
            }
            Uri apiEndpoint = new Uri(Utils.GetFileApi() + "/" + fileId + "/metadata");
            HttpResponseMessage response = Utils.Get(apiEndpoint, (string)options["privateKey"]);

            response.EnsureSuccessStatusCode();
            using (var responseContent = response.Content.ReadAsStringAsync())
            {
                MetadataResponse resp = JsonConvert.DeserializeObject <MetadataResponse>(responseContent.Result);
                resp.StatusCode = response.StatusCode.ToString();
                return(resp);
            }
        }
Exemplo n.º 3
0
        public async Task <MetadataResponse> GetFileMetadataAsync(Uri uri)
        {
            if (!Utils.IsValidURI(uri.OriginalString))
            {
                throw new ArgumentException(errorMessages.INVALID_URI);
            }
            Uri apiEndpoint = new Uri(Utils.GetApiHost() + "/v1/metadata?url=" + uri.AbsoluteUri);
            HttpResponseMessage response = await Utils.GetAsync(apiEndpoint, (string)options["privateKey"]).ConfigureAwait(false);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var requestId = response.Headers.GetValues("x-ik-requestid").FirstOrDefault();

            MetadataResponse resp = JsonConvert.DeserializeObject <MetadataResponse>(responseContent);

            resp.StatusCode   = (int)response.StatusCode;
            resp.XIkRequestId = response.Headers.FirstOrDefault(x => x.Key == "x-ik-requestid").Value?.First();
            return(resp);
        }