Fabric中访问文件系统

Fabric中访问文件系统

本文介绍了在Service Fabric中访问文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从服务总线队列收到新消息时,我需要在Service Fabric服务中使用ffmpeg对视频进行编码.我可以从资源中提取ffmpeg.exe并运行它,但是我可以将输入/输出视频文件保存在内部文件系统中吗?

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?

推荐答案

我通过以下代码在本地群集上对其进行了测试:

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);
        }
    }

结果输出为:

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

但是下次运行时路径已更改为C:\ SfDevCluster \ Data_App_Node_3 \ SampleAppType_App52 \ work \ testFile.txt.

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

所以我想答案是:

可以使用本地文件系统,但只能用于临时文件.而且我认为在迭代结束时清理系统是个好习惯.

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.

这篇关于在Service Fabric中访问文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:32