What is the intended way to store temporary files? Is there an API and if no, how would i ensure "cleanup"? Thank you
Community moderators have prevented the ability to post new answers.
Just use the JVM's configured "temp" directory; this is configured to point to the correct location.
An easy way to do this would be to use the File.createTempFile method, for example.
EDIT: My original answer above is wrong! You should use the temp directory that is create in the Confluence data directory (also referred to as the Confluence "home" directory). You can build a path to this folder with the following code:
File tempDirectory = new File(bootstrapManager.getConfluenceHome(), ConfluenceHomeGlobalConstants.TEMP_DIR);
There is a scheduled job in Confluence that runs once a day to clean up old files in this directory.
interesting. but what about those temp folders for plugins and how to use PluginDirectoryProvider? I mean, all those things are just nonsense?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
They're not nonsense, they're just not intended for you to use - they're part of the way the plugin framework extracts and loads your plugin into the host application.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for helping me.
Ok just some simple quesions, so i get those things straight:
- so there is no special tmp folder for a plugins (storage like /plugins/myplugin/temp)
- i should not use BootstrapManager::getConfluenceHome() + "/temp" for tmp folder, since that could be reconfigured, right?
- the temp folder configured with the JVM is the one getting cleaned up by confluence, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, I'm sorry I've steered you in the wrong direction here! My recollection was different to the actual code, which I've now looked into.
The temporary directory you should be using is _not_ the JVM-configured temp directory, but the temp directory in the Confluence data directory. The JVM-configured temp directory will be the temp directory of the application server for the Confluence webapp, so it's probably going to be something like "${TOMCAT_INSTALLATION_DIR}\temp".
There's nothing wrong with using's the app server's temp directory, but if you use the Confluence temp directory, there is a scheduled job that runs within Confluence that automatically cleans up old files once a day.
So you're right, you should use "BootstrapManager::getConfluenceHome() + "/temp".
You shouldn't put anything in the "/plugins" folder, since this folder is where the plugin framework runs from and you might confuse it by putting random files in there.
Apologies for the confusion! I'll update my original answer for anyone else who comes across this in the future.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
glad we put that right, thank you very much! I already testing it, work perfect/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, but just to have this all together, iam doing this for dependency injections (spring) for BoostrapManager, but later on i get a nullpointer exception on this.bootstrapManager ... its not early in the bootphase, so it should work. Any idea here? Do i need to add anything in the atlassion-plugin.xml?
private BootstrapManager bootstrapManager; public void setBootstrapManager(BootstrapManager bootstrapManager) { this.bootstrapManager = bootstrapManager; }
if i use this before using it, it works..but thats not the intended way:
BootstrapManager bootManager = (BootstrapManager) ContainerManager.getComponent("bootstrapManager");
<body></body>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
bootstrapManager.getConfluenceHome() has been deprecated since Confluence 5.5. Use bootstrapManager.getLocalHome() instead. See https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/setup/BootstrapManager.html#getLocalHome%28%29
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i could of course use BootstrapManager::getConfluenceHome() + "/temp" ... but that sounds pretty wrong. Could someone at least tell me if this is best practice?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i stumbeled uppon PluginDirectoryProvider and thought its auto-wired using spring, but thats not happening. How woould i user any (central) ?singleton? to get an object implementing this interface for (my) plugin?
It cant be that hard saving files into a temporary folder, or?
I really cant find anything usefull in the docs at all..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.