isFile() private method

private isFile ( ) : bool
return bool
Esempio n. 1
0
        public void TestTikaAutodetect()
        {
            Tika tika = new Tika();
            File xpsFile = new File("samples\\test1.xps");
		    if (!xpsFile.isFile())
			    throw new Exception(xpsFile.getName() + " does not exists.");

            using (InputStream inputStream = new FileInputStream(xpsFile))
            {
                Metadata metadata = new Metadata();

                string mimeType = tika.detect(inputStream, metadata);
                Assert.AreEqual("application/x-tika-ooxml", mimeType);

                inputStream.close();
            }
        }
        public void GetEXIF(string path, Action<string> yield)
        {

            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            var filepath = path.SkipUntilIfAny(io);

            if (is_thumb)
            {
                filepath = path.SkipUntilIfAny(thumb);
            }

            // is this still a problem?
            filepath = filepath.Replace("%20", " ");

            var file = new File(filepath);


            if (file.exists())
                if (file.isFile())
                    if (path.EndsWith(".jpg"))
                    {

                        //file.print(yield);

                    }
        }
        // refactor this into separate partial class file
        public void Handler(WebServiceHandler h)
        {


            var path = h.Context.Request.Path;

            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            if (is_io || is_thumb)
            {


                var filepath = path.SkipUntilIfAny(io);

                if (is_thumb)
                {
                    filepath = path.SkipUntilIfAny(thumb);
                }

                // is this still a problem?
                filepath = filepath.Replace("%20", " ");

                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = InternalReadBytes(filepath, is_thumb);

                            h.Context.Response.ContentType = "image/jpg";

                            // http://www.webscalingblog.com/performance/caching-http-headers-cache-control-max-age.html
                            h.Context.Response.AddHeader("Cache-Control", "max-age=2592000");

                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }

                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }
        // refactor this into separate partial class file
        public void InternalHandler(WebServiceHandler h)
        {
            // HTTP routing? how to do this more elegantly?
            service.InternalHandler(h);

            var Host = h.Context.Request.Headers["Host"].TakeUntilIfAny(":");

            var path = h.Context.Request.Path;

            if (h.IsDefaultPath)
            {
                if (!h.Context.Request.QueryString.AllKeys.Contains("about"))
                    if (Host == h.Context.Request.UserHostAddress)
                    {
                        //h.Context.Response.SetCookie(new System.Web.HttpCookie("about", "me"));

                        //System.Console.WriteLine("open this in laptop");

                        h.Context.Response.Redirect("/?about=me");
                        h.CompleteRequest();

                        return;
                    }
            }



            var is_io = path.StartsWith(io);
            var is_thumb = path.StartsWith(thumb);

            if (is_io || is_thumb)
            {


                var filepath = path.SkipUntilIfAny(io);

                if (is_thumb)
                {
                    filepath = path.SkipUntilIfAny(thumb);
                }

                // is this still a problem?
                filepath = filepath.Replace("%20", " ");

#if Android
                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = InternalReadBytes(filepath, is_thumb);

                            h.Context.Response.ContentType = "image/jpg";

                            // http://www.webscalingblog.com/performance/caching-http-headers-cache-control-max-age.html
                            h.Context.Response.AddHeader("Cache-Control", "max-age=2592000");

                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }
#endif


                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }
        // how does this relate to SSL/ and ServiceWorker?
        public void Handler(WebServiceHandler h)
        {
            var io = "/io";
            var path = h.Context.Request.Path;
            if (path.StartsWith(io))
            {


                var filepath = path.SkipUntilIfAny(io);

                filepath = filepath.Replace("%20", " ");

                var file = new File(filepath);


                if (file.exists())
                    if (file.isFile())
                        if (path.EndsWith(".jpg"))
                        {
                            var bytes = System.IO.File.ReadAllBytes(filepath);

                            h.Context.Response.ContentType = "image/jpg";


                            // send all the bytes

                            h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length);



                            h.CompleteRequest();
                            return;
                        }

                h.Context.Response.ContentType = "text/html";
                h.Context.Response.Write("what ya lookin for?");
                h.Context.Response.Write(new XElement("pre", filepath).ToString());
                h.CompleteRequest();
                return;
            }
        }