开发者

How to get images from cache using a XPCOM Component in Firefox

I need to get the cache file path for ever image lo开发者_高级运维aded in a document, I am wondering what are the Interfaces I need to use in order to do that

https://developer.mozilla.org/en/XPCOM_Interface_Reference


This is what I used to evict cache entry:

  function removeItem(url){
    let cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
                            .getService(Components.interfaces.nsICacheService);
    var Ci = Components.interfaces;
    var session = cacheService.createSession("image", Ci.nsICache.STORE_ANYWHERE, false);
    if(!session){
        return;
    }

    var entry;
    try{
        entry = session.openCacheEntry(url, Ci.nsICache.ACCESS_READ, false);
        if(!entry){
            return;
        }
    }catch(ex){
        return;
    }

    entry.doom();
    entry.close();
  }
}

Once you have entry you should be able to open a stream to it - possibly getting the content or even replacing it - I haven't tried it though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜