/// <summary> /// Encrypt, Split, Upload the text on IPFS and Timestamp on DCore /// </summary> /// <param name="file">filepath</param> //string[] void EncryptSplitUploadText(string file) { //We encrypt string encryptedFile = Encryption.EncryptTextFile(file); //We split string[] splittedFile = Split.SplitFile(encryptedFile); //Update or Create new Entry? bool FileExist = fs.SearchFileByPathBlockgetFS(file); List <string> EntryFileCid = new List <string> { file, "", "", "" }; // We can send for (int i = 0; i <= Globals.SPLIT_NB - 1; i++) { Console.WriteLine("Adding {0} at position {1} for {2} entry", splittedFile[i], i + 1, file); //S2 - reference IpfsUploadDCore(splittedFile[i], i + 1, EntryFileCid); } //Add or Update? => Check if it exist or not if (FileExist) { Console.WriteLine("The file {0} already exist in Blockget, we update"); fs.UpdateEntryListFileNamesCids(file, EntryFileCid); } else { Console.WriteLine("Creating a new file in Blockget File System"); fs.AddEntryListFileNamesCids(EntryFileCid); } //We delete the temp files: //foreach (string tempFile in splittedFile) { // File.Delete(tempFile); //} }
/// <summary> /// Search button: in the Hash table or HashSet Blockget File System /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchButton_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(FilenameBlockgetSearchTextBox.Text)) { //if (listFileNamesCids.Contains(FilenameBlockgetSearchTextBox.Text)) // Console.WriteLine("The item {0} has been found in the Blockget File System.", FilenameBlockgetSearchTextBox.Text); //Look for the filename in the blockget file system if (!fs.SearchFileByPathBlockgetFS(FilenameBlockgetSearchTextBox.Text)) { Console.WriteLine("Couldn't find by path so we look for a filename"); richTextBox1.Text = "File found there:" + fs.SearchFileByNameBlockgetFS(FilenameBlockgetSearchTextBox.Text); } else { Console.WriteLine("Find the file by path"); } } else { Console.WriteLine("There is nothing to search for"); } }