public void Init() { RootDir = FileUtil.CreateTempFolder("_" + GetType().Name); var provider = new LocalFileSystemProvider(RootDir, true); //prepare test dir and paths DownloadService = (LocalFileSystemDownloadService) provider.DownloadTransfers; SourceFilePath = FileUtil.CreateTempFilePath(RootDir.FullName, "source", "bin"); //create file SourceFileContents = new byte[5 * 1024 * 1024]; new Random(DateTime.Now.Millisecond).NextBytes(SourceFileContents); File.WriteAllBytes(SourceFilePath, SourceFileContents); SourceFile = new FileInfo(SourceFilePath); //prepare target buffer ReceivingBuffer = new List<byte>(); LastBlock = null; //get token Token = DownloadService.RequestDownloadToken(SourceFilePath, false); InitInternal(); }
public void Configure() { var root = new DirectoryInfo(@"D:\Downloads\1-Time Garbage\_VFS-SERVICE-ROOT"); var fsConfig = LocalFileSystemConfiguration.CreateForRootDirectory(root, true); fsConfig.RootName = "Downloads"; var provider = new LocalFileSystemProvider(fsConfig); using (OpenRastaConfiguration.Manual) { var uris = VfsUris.Default; // ConfigurationHelper.RegisterExceptionInterceptor(); ConfigurationHelper.RegisterFileSystemProvider(provider); ConfigurationHelper.RegisterDefaultHandlers(); // //read file as stream // ResourceSpace.Has.ResourcesOfType<FileDataResource>() // .AtUri("/files/{filepath}/data") // .HandledBy<DownloadHandler>(); // // //get download token // ResourceSpace.Has.ResourcesOfType<DownloadToken>() // .AtUri("/files/{filepath}/download/token?includefilehash={includeFileHash}") // .And // .AtUri("/files/{filepath}/download/token?includefilehash={includeFileHash}&maxblocksize={maxBlockSize}") // .HandledBy<DownloadHandler>() // .AsXmlDataContract(); } }
static void Main(string[] args) { LocalFileSystemProvider lp = new LocalFileSystemProvider(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),true); bool exfd= lp.ExistFolder("LocalVFS",true); if (exfd) { lp.DeleteFolder("LocalVFS"); } byte[] dataTest = Encoding.UTF8.GetBytes("this is a test context!!!"); File.WriteAllBytes("test.cs",dataTest); lp.CreateFolder("LocalVFS"); string filepath= lp.CreateFilePath("LocalVFS", "test.txt"); //lp.MoveFile("test.cs", filepath); byte[] dataTest2 = Encoding.UTF8.GetBytes("this is a test write data!!!"); using (MemoryStream ms = new MemoryStream(dataTest2)) { lp.WriteFile("LocalVFS/test.txt",ms, true, dataTest2.Length, ContentUtil.UnknownContentType); } //lp.DeleteFile("LocalVFS/test.txt"); lp.CopyFolder("LocalVFS", "localvfs_test"); lp.Dispose(); int jj = 0; }
static void Main(string[] args) { LocalFileSystemProvider lp = new LocalFileSystemProvider(new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory), true); bool exfd = lp.ExistFolder("LocalVFS", true); if (exfd) { lp.DeleteFolder("LocalVFS"); } byte[] dataTest = Encoding.UTF8.GetBytes("this is a test context!!!"); File.WriteAllBytes("test.cs", dataTest); lp.CreateFolder("LocalVFS"); string filepath = lp.CreateFilePath("LocalVFS", "test.txt"); //lp.MoveFile("test.cs", filepath); byte[] dataTest2 = Encoding.UTF8.GetBytes("this is a test write data!!!"); using (MemoryStream ms = new MemoryStream(dataTest2)) { lp.WriteFile("LocalVFS/test.txt", ms, true, dataTest2.Length, ContentUtil.UnknownContentType); } //lp.DeleteFile("LocalVFS/test.txt"); lp.CopyFolder("LocalVFS", "localvfs_test"); lp.Dispose(); int jj = 0; }