Setting the Aspose.Imaging.Cache.CacheFolder has no effect

Hi Team!
I’m using Aspose.Imaging to convert vector graphical images to raster image. I noticed that during the conversions temporary files are created on /tmp/Aspose.Imaging/ directory. In my use case my application sould not access the /tmp directory.

I saw that there is a Aspose.Imaging.Cache class where I can customize the CacheFolder. I set the CacheFolder to my custom directory but it seems like it doesn’t have any effect, temp files are still created in the /tmp.

I used fatrace to monitor filesystem access. The command: sudo fatrace -t | grep '/tmp/Aspose' > fatrace.log

My questions:

  1. How can I prevent Aspose.Imaging library to accessing the /tmp directory?
  2. My other question what will happens with the file conversion if my application doesn’t have rights to access the /tmp dir?

Sample project: AsposeImagingVectorImage.zip (2.5 KB)
Test files: vector-images.zip (326.5 KB)
File access log: fatrace.zip (8.8 KB)

OS: Ubuntu 22.04 (Linux)
Aspose.Imaging version: 24.12.0

@erdeiga

To prevent the Aspose.Imaging library from accessing the /tmp directory and to set a custom cache folder, you can utilize the Cache.CacheFolder property. However, it seems that you are experiencing issues where the temporary files are still being created in the /tmp directory despite setting this property.

Here are some steps you can take to address your concerns:

  1. Setting the Cache Folder: Ensure that you are setting the Cache.CacheFolder property correctly in your code before any image processing occurs. Here’s an example of how to set it:

    // Set the custom cache folder
    Cache.setCacheFolder("path/to/your/custom/directory");
    

    Make sure that the specified directory exists and that your application has the necessary permissions to write to it.

  2. Environment Variable: In addition to setting the cache folder in your code, you can also set the TEMP environment variable before running your application. This can be done in your terminal as follows:

    export TEMP=/path/to/your/custom/directory
    

    This approach may help redirect the temporary file creation to your specified directory.

  3. Permissions: If your application does not have rights to access the /tmp directory, it may lead to exceptions or failures during file conversion. It is crucial to ensure that your application has the necessary permissions to access the directory you are using for caching.

  4. Monitoring File Access: Since you are already using fatrace to monitor filesystem access, continue to check the logs after making the above changes to confirm that the temporary files are being created in the desired location.

If the issue persists, it may be beneficial to reach out to Aspose support for further assistance, as there might be an underlying issue with the library’s handling of the cache folder settings.

For more information on managing cache settings in Aspose.Imaging, you can refer to the official documentation or community discussions related to this topic.

Sources:
[1]: Temp directory in Aspose Imaging

Hi, @erdeiga
We appreciate you providing this information. We will check this and inform you about the results.

Best regards

1 Like

Hi, @erdeiga

Cache.CacheFolder is a folder for storing the file stream cache. Other Aspose temporary files are stored in the directory specified in the environment variable TEMP.
As a result, the only option available to you for solving the problem is to modify the environment variable.

Best regards

1 Like

Hi @Nikita_Romanov, thank you for the quick answer. It is working but on Linux I had to set the “TMPDIR” variable.