Skip to content

Redirecting the workspace to another location, as shown in the readme, doesn't work #27

Description

@wags1999

The readme contains these instructions for redirecting the workspace, using ArtifactStorageOptions.WorkspacePathFormatter to override the path:

var workspaceRoot = Path.Combine(Path.GetTempPath(), "markitdown", "workspaces");

var options = new MarkItDownOptions
{
    ArtifactStorage = ArtifactStorageOptions.Default with
    {
        WorkspacePathFormatter = name => Path.Combine(workspaceRoot, name),
        DeleteOnDispose = false    // keep the workspace directory after conversion
    },
    SegmentOptions = SegmentOptions.Default with
    {
        Image = SegmentOptions.Default.Image with
        {
            KeepArtifactDirectory = true
        }
    }
};

Directory.CreateDirectory(workspaceRoot);

await using var client = new MarkItDownClient(options);
await using var result = await client.ConvertAsync("policy.pdf");

However, before the call to the WorkspacePathFormatter is invoked on line 36:

var directoryPath = storageOptions.WorkspacePathFormatter?.Invoke(workspaceName)

On lines 27-32, if the StorageFactory was not setup on the options, a default path will be returned:
if (storageFactory is null)
{
var localDirectory = BuildLocalWorkspacePath(streamInfo, segmentOptions.Image);
var deleteOnDispose = storageOptions.DeleteOnDispose && !segmentOptions.Image.KeepArtifactDirectory;
return ArtifactWorkspace.Create(localDirectory, deleteOnDispose, ensureCreated: true);
}

Using ManagedCode.MarkItDown 10.0.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions