0

Oracle Cloud Infrastructure iaas にファイルをアップロードしようとしていますが、GetRequestStream() を使用してストリームを書き込んでいるときに操作がタイムアウトするなどのエラーが見つかりました。投稿しようとしているファイルの順序が正しいかどうかも確認してください。

            FileInfo f = new FileInfo(FileUpload1.FileName);
            byte[] filebyte =FileUpload1.FileBytes;

            var postdata = Encoding.UTF8.GetBytes(filebyte.ToString());


            var tenancyId = ConfigurationManager.AppSettings["BMCTenancyId"];
            var userId = ConfigurationManager.AppSettings["BMCUserId"];
            var fingerprint = ConfigurationManager.AppSettings["BMCFingerprint"];
            var privateKeyPath = ConfigurationManager.AppSettings["BMCPrivateKeyPath"];
            var privateKeyPassphrase = ConfigurationManager.AppSettings["BMCPrivateKeyPassphrase"];

            var signer = new RequestSigner(tenancyId, userId, fingerprint, privateKeyPath, privateKeyPassphrase);

           // ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var uri = new Uri($"https://objectstorage.us-phoenix-1.oraclecloud.com/");

            var request = (HttpWebRequest)WebRequest.Create(uri);
            request.Method = "POST";
            request.Accept = "application/json";
            request.SendChunked = true;
            request.ContentType = "text/plain";
             request.KeepAlive = true;
            request.AllowWriteStreamBuffering = false;
            request.ContentLength =postdata.Length;



        try
        {

            using (var stream = request.GetRequestStream())
            {
                stream.Write(postdata, 0, postdata.Length);

            }
        }
        catch(Exception ex)
        {
            Response.Write("testing"+ex.Message+"Tedting");

        }



            request.Headers["x-content-sha256"] = Convert.ToBase64String(SHA256.Create().ComputeHash(postdata));
4

1 に答える 1