示例#1
0
        private void Page_Load(object sender, EventArgs e)
        {
            TextData = Request.QueryString ["text"];

            FolderName = Request.QueryString ["folder"];

            FileName = Request.QueryString ["file"];

            Overwrite = Convert.ToBoolean(Request.QueryString ["overwrite"]);

            if (!String.IsNullOrEmpty (TextData)) {
                DidPublish = true;

                var echo = new ipfsEcho ();
                echo.IsVerbose = true;

                if (String.IsNullOrEmpty (FolderName)) {
                    var hash = echo.Echo (TextData);

                    CreateIpfsUrls (hash);

                } else {
                    var peerId = echo.Echo (TextData, FolderName, FileName, Overwrite);

                    CreateIpnsUrls (peerId, FolderName, FileName);
                }
            }
        }
        public override void Execute()
        {
            var echo = new ipfsEcho ();
            echo.IsVerbose = true;
            echo.Init ();

            var firstString = "one";

            var subFolderName = Guid.NewGuid().ToString();

            var peerId = echo.Echo (firstString, subFolderName);

            Console.WriteLine(peerId);

            var fileChecker = new ipfsFileChecker ();

            var relativeFilePath = subFolderName + "/data.txt";

            fileChecker.CheckTestFile ("ipns", peerId, relativeFilePath, firstString);

            var secondString = "two";

            peerId = echo.Echo (secondString, subFolderName);

            var combinedString = firstString + Environment.NewLine + secondString;

            fileChecker.CheckTestFile ("ipns", peerId, relativeFilePath, combinedString);
        }
示例#3
0
        public static void Main(string[] args)
        {
            var location = args [0];

            var echo = new ipfsEcho ();

            var sensor = new TemperatureSensor ();

            while (true){
                var temperature = sensor.GetTemperature (location);

                var line = String.Format("Date: {0}; Temperature: {1}c;", DateTime.Now.ToString(), temperature);

                Console.WriteLine (line);

                echo.Echo(line, "TemperatureData");

                Thread.Sleep (30000);

                Console.WriteLine ("");
            }
        }
示例#4
0
        public static void Main(string[] args)
        {
            var arguments = new Arguments (args);

            if (arguments.KeylessArguments.Length == 0)
                throw new ArgumentException ("Some text must be provided as an argument.");

            var text = arguments.KeylessArguments [0];

            var hashOnly = arguments.Contains ("h")
                || arguments.Contains("hash");

            var showPath = arguments.Contains ("p")
                || arguments.Contains("path");

            var longOutput = arguments.Contains ("l")
                || arguments.Contains("long");

            var showLink = arguments.Contains ("link");

            var replace = arguments.Contains ("replace");

            var publishKey = arguments["publish"];

            var fileName = arguments["fileName"];

            if (String.IsNullOrEmpty (fileName))
                fileName = "data.txt";

            if (longOutput)
            {
                if (showLink == false)
                    showLink = true;
                if (showPath == false)
                    showPath = true;
            }

            var echo = new ipfsEcho ();

            var hash = echo.Echo (text, publishKey, fileName, replace);

            // TODO: Clean up the output code. Currently the ipfsEcho class outputs during publish, but this console outputs during standard echo.
            // The location of the output code should be more consistent
            if (String.IsNullOrEmpty (publishKey)) {
                if (hashOnly) {
                    Console.WriteLine (hash);
                } else {
                    Console.WriteLine ("Hash: " + hash);
                }

                var protocol = (!String.IsNullOrEmpty (publishKey) ? "ipns" : "ipfs");

                if (showLink) {
                    var link = "URL: https://ipfs.io/" + protocol + "/" + hash;
                    Console.WriteLine (link);
                }

                if (showPath) {
                    var path = "Path: /" + protocol + "/" + hash;
                    Console.WriteLine (path);
                }
            }
        }