问题
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