Access file system in Service Fabric

白昼怎懂夜的黑 提交于 2019-12-05 01:22:04

问题


I need to encode video using ffmpeg in Service Fabric service when I receive new message from Service Bus queue. I can extract ffmpeg.exe from resources and run it but can I save input/output video files in internal file system?


回答1:


I tested it on local cluster by following code:

    protected override async Task RunAsync(CancellationToken cancellationToken)
    {
        while (true)
        {
            cancellationToken.ThrowIfCancellationRequested();

            string filename = "testFile.txt";
            File.AppendAllText(filename, "test. ");

            string content = File.ReadAllText(filename);
            System.Diagnostics.Trace.WriteLine("Content:" + content);
            System.Diagnostics.Trace.WriteLine(new FileInfo(filename).FullName);

            await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
        }
    }

The result output was:

Content:test. 
C:\SfDevCluster\Data\_App\_Node_3\SampleAppType_App51\work\testFile.txt
Content:test. test. 
C:\SfDevCluster\Data\_App\_Node_3\SampleAppType_App51\work\testFile.txt
Content:test. test. test. 
C:\SfDevCluster\Data\_App\_Node_3\SampleAppType_App51\work\testFile.txt

But path was changed on the next run to C:\SfDevCluster\Data_App_Node_3\SampleAppType_App52\work\testFile.txt.

So I suppose the answer is:

It's possible to use local file system but only for temporary files. And I think it's a good practice to clean up the system at the end of iteration.



来源:https://stackoverflow.com/questions/37965123/access-file-system-in-service-fabric

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!