Atozed Forums
getting absolute local path to a cached file - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: getting absolute local path to a cached file (/thread-2634.html)



getting absolute local path to a cached file - iwuser - 02-09-2022

I'm adding temp files using something like:

sTempFileName := TIWAppCache.StreamToCacheFile(self, ...

And sTempFileName works fine as a URI (i.e.: in a IWURLWindow1.URI), because it's a valid relative URI.

But I need to get a local absolute path to this file in the server-side code, hopefully easier than parsing WebApplication.UserCacheDir, etc.

Is there a direct way of doing this?


RE: getting absolute local path to a cached file - iwuser - 02-10-2022

Actually, this may not be very reliable, because these .tmp files have internal caching data appended to them. So I'll need to reshuffle all this anyway.


RE: getting absolute local path to a cached file - kudzu - 02-11-2022

Correct, they do have info in them.


RE: getting absolute local path to a cached file - kudzu - 02-11-2022

The source code can offer you a stream from them though and it removes the extra info if you can use a stream instead of a file itself.


RE: getting absolute local path to a cached file - iwuser - 02-11-2022

(02-11-2022, 12:22 AM)kudzu Wrote: The source code can offer you a stream from them though and it removes the extra info if you can use a stream instead of a file itself.

That would be great, thanks, because I can. What object.method is it in?


RE: getting absolute local path to a cached file - Alexandre Machado - 02-14-2022

The cache file is stored in

ServerController.CacheDir

http://docs.atozed.com/docs.dll/classes/TIWServerControllerBase.html

Regarding the cache, there is some information here:

http://docs.atozed.com/docs.dll/development/Migrating%20to%20IntraWeb%20XIV.html#Cache

and here

http://docs.atozed.com/docs.dll/Classes/TIWAppCache.html


RE: getting absolute local path to a cached file - iwuser - 02-14-2022

(02-14-2022, 06:07 AM)Alexandre Machado Wrote: The cache file is stored in

ServerController.CacheDir

http://docs.atozed.com/docs.dll/classes/TIWServerControllerBase.html

Regarding the cache, there is some information here:

http://docs.atozed.com/docs.dll/development/Migrating%20to%20IntraWeb%20XIV.html#Cache

and here

http://docs.atozed.com/docs.dll/Classes/TIWAppCache.html

Ok, thanks. BUt I cannot see how to get a stream of an already cached file. All these methods would create a cache file from my stream, I need the reverse.


RE: getting absolute local path to a cached file - Alexandre Machado - 02-24-2022

There is a rule of thumb with the cache system: once you add something to the cache, you should just forget about it... :-)
It doesn't belong to you anymore. The cache file is not only the data that you put in there. It is your data + some metadata containing important information about the cache file itself.

Can you please explain why do you need to read the cache file after you saved your own data to it? Wouldn't be easier to read/store this data before adding it to the cache?


RE: getting absolute local path to a cached file - iwuser - 02-24-2022

(02-24-2022, 10:14 AM)Alexandre Machado Wrote: There is a rule of thumb with the cache system: once you add something to the cache, you should just forget about it... :-)
It doesn't belong to you anymore. The cache file is not only the data that you put in there. It is your data + some metadata containing important information about the cache file itself.

Can you please explain why do you need to read the cache file after you saved your own data to it? Wouldn't be easier to read/store this data before adding it to the cache?

My problem is that I'm creating these files elsewhere first and then later I may need them again, but here I do not want to re-acquire them all over again from where I got them in the first place. So, because I have already created these caches, it would be ideal for me to use them.

Interestingly enough, I could still use the files as they are, with the appended IW details, it does not seem to cause me any problems, but I suppose that it could. These caches are also good for me in that I do not need any extra maintenance in terms of deleting them in the end, IW does this for me already.

So, if I have to re-read the data and create duplicate files (which is a performance hit and a duplication of effort), I would then also have to remember to delete them in the end. Which is what I'm trying to avoid.