コード例 #1
0
        private void PushApplicationToKobiton(AppURL appUrl, FileInfo file)
        {
            if (appUrl == null || string.IsNullOrEmpty(appUrl.Url))
            {
                throw new ArgumentNullException(nameof(appUrl));
            }

            Console.WriteLine($"{DateTime.UtcNow:HH:mm:ss:fff} KobitonAPI: PushApplicationToKobiton {file.FullName}");

            HttpWebRequest httpRequest = WebRequest.Create(appUrl.Url) as HttpWebRequest;

            httpRequest.Method = "PUT";

            httpRequest.ContentType = "application/octet-stream";
            httpRequest.Headers.Add("x-amz-tagging", "unsaved=true");

            using (Stream dataStream = httpRequest.GetRequestStream())
            {
                byte[] buffer = new byte[8000];
                using (FileStream fileStream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
                {
                    int bytesRead = 0;
                    while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        dataStream.Write(buffer, 0, bytesRead);
                    }
                }
            }

            HttpWebResponse response = httpRequest.GetResponse() as HttpWebResponse;
        }
コード例 #2
0
        private int NotifyKobitonOfUpload(AppURL appUrl, FileInfo file)
        {
            Console.WriteLine($"{DateTime.UtcNow:HH:mm:ss:fff} KobitonAPI: NotifyKobitonOfUpload {file.FullName}");

            var request = new RestRequest("apps", Method.POST);

            request.AddHeader("Authorization", send);
            request.AddHeader("content-type", "application/json");

            request.AddJsonBody(new
            {
                filename = file.Name,
                appPath  = appUrl.AppPath,
            });

            var response = client.Execute <AppIdentification>(request);

            return(response.Data.AppId);
        }