Beispiel #1
0
        public void testRemoteStreamsFileStream()
        {
            log.info("testRemoteStreamsFileStream(");
            String   str  = "hallo";
            FileInfo file = new FileInfo(Path.GetTempFileName() + " € ß.txt");

            File.WriteAllText(file.FullName, str);
            BContentStream istrm = new BContentStreamWrapper(file.OpenRead(), "text/plain", file.Length);

            istrm.FileName = file.Name;
            remote.SetImage(istrm);
            BContentStream istrmR = (BContentStream)remote.GetImage();

            TestUtils.assertEquals(log, "Content-Type", "text/plain", istrmR.ContentType);
            TestUtils.assertEquals(log, "Content-Length", file.Length, istrmR.ContentLength);
            TestUtils.assertEquals(log, "FileName", file.Name, istrmR.FileName);

            ByteBuffer buf  = BWire.bufferFromStream(istrmR, false);
            String     strR = File.ReadAllText(file.FullName);

            TestUtils.assertEquals(log, "stream", str, strR);

            TestUtils.assertEquals(log, "Content-Type", "text/plain", istrmR.ContentType);
            TestUtils.assertEquals(log, "Content-Length", file.Length, istrmR.ContentLength);
            TestUtils.assertEquals(log, "FileName", file.Name, istrmR.FileName);

            file.Delete();
            log.info(")testRemoteStreamsFileStream");
        }
Beispiel #2
0
        /// <summary>
        /// Upload stream to given URL.
        /// </summary>
        /// <param name="url">Destination URL</param>
        /// <param name="fstream">Stream</param>
        /// <param name="contentType">Content type</param>
        /// <param name="contentLength">Content length</param>
        /// <returns></returns>
        public virtual String Upload(String url, Stream fstrm, String contentType, long contentLength)
        {
            String[]       params1 = makeRawStreamServiceParamsFromUrl(url);
            BContentStream cs      = new BContentStreamWrapper(fstrm, contentType, contentLength);
            String         ret     = bclient.RawStreamService.upload(params1, cs);

            return(ret);
        }