Ejemplo n.º 1
0
        private static bool putObject()
        {
            try
            {
                Console.WriteLine("--- Upload a File ---");

                FileInfo         file             = new FileInfo("H:/haixt111/[email protected]");//  d:/test1.doc
                PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objKeyNameFileData, file);

                //CannedAccessControlList cannedAcl = new CannedAccessControlList(CannedAccessControlList.PRIVATE);
                //putObjectRequest.setCannedAcl(cannedAcl);

                SampleListener sampleListener = new SampleListener(file.Length);
                putObjectRequest.setProgressListener(sampleListener);
                PutObjectResult putObjectResult = ks3Client.putObject(putObjectRequest);

                Console.WriteLine("Upload Completed. eTag=" + putObjectResult.getETag() + ", MD5=" + putObjectResult.getContentMD5());
                Console.WriteLine("---------------------\n");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private static bool putObject()
        {
            try
            {
                //Console.WriteLine("--- create a folder: ---");
                //Stream streamNull = new MemoryStream();
                //PutObjectResult createFolder = ks3Client.putObject("bucketcors", "jrtest", streamNull, null);
                //Console.WriteLine("---------------------\n");

                //// Put Object(upload a short content)
                //Console.WriteLine("--- Upload a Short Content: ---");
                //String sampleContent = "This is a sample content.(25 characters before, included the 4 spaces)";
                //Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(sampleContent));
                //PutObjectResult shortContentResult = ks3Client.putObject("bucketcors", "jrtest/aa", stream, null);

                //Console.WriteLine("Upload Completed. eTag=" + shortContentResult.getETag() + ", MD5=" + shortContentResult.getContentMD5());
                //Console.WriteLine("-------------------------------\n");

                //Put Object(upload a file)
                Console.WriteLine("--- Upload a File ---");
                bucketName         = "kingsoft.test.ml";
                objKeyNameFileData = "testPut2.mp4";
                FileInfo                file             = new FileInfo("d:/hengping.mp4");
                PutObjectRequest        putObjectRequest = new PutObjectRequest(bucketName, objKeyNameFileData, file);
                CannedAccessControlList cannedAcl        = new CannedAccessControlList(CannedAccessControlList.PRIVATE);
                putObjectRequest.setCannedAcl(cannedAcl);

                SampleListener sampleListener = new SampleListener(file.Length);
                putObjectRequest.setProgressListener(sampleListener);
                PutObjectResult putObjectResult = ks3Client.putObject(putObjectRequest);

                Console.WriteLine("Upload Completed. eTag=" + putObjectResult.getETag() + ", MD5=" + putObjectResult.getContentMD5());
                Console.WriteLine("---------------------\n");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public void TestPutObject()
        {
            if (init())
            {
                Stream          streamNull   = new MemoryStream();
                PutObjectResult createFolder = ks3Client.putObject("test2-zzy-jr", "jrtest", streamNull, null);

                // Put Object(upload a short content)

                String          sampleContent      = "This is a sample content.(25 characters before, included the 4 spaces)";
                Stream          stream             = new MemoryStream(Encoding.UTF8.GetBytes(sampleContent));
                PutObjectResult shortContentResult = ks3Client.putObject("test2-zzy-jr", "jrtest/aa", stream, null);

                //FileInfo file = new FileInfo("E:\\tool\\eclipse.rar");
                //PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objKeyNameFileData, file);
                //PutObjectResult putObjectResult = ks3Client.putObject(putObjectRequest);

                Assert.IsNotNull(shortContentResult.getETag());
            }
        }