2017-12-06 11 views
0

Google의 반응 프로젝트에서 우리는 이미지 URL 뒤에 서명 키가있는 이미지 URL을 얻었습니다. http://my_bucket.s3.amazon.com/my_profile.jpg?signing_key=I_am_changeable_every_time처럼. 네이티브 이미지 캐시에 반응 이미지 URL에 대한 쿼리 매개 변수를 무시하십시오.

우리는 다음과 같은 위의 URL을 보여

<ImageView source={{ uri: photo.uri }} />

우리는 우리를 위해 이미지 캐시를 처리 할 수있는 기본 이미지 구성 요소를 반응합니다. 반응하는 네이티브 이미지 구성 요소는 매번 이미지를로드합니다. 한 가지 가능한 이유는 반응 네이티브 이미지 구성 요소가 실제로 캐시 작업을 수행하지 않는다는 것입니다.

그러면 외부를 찾으려고합니다. react-image-cache library.

그러나 대부분의 이미지 캐시 라이브러리는 전체 이미지 URL을 캐시 키로 취급합니다. 우리의 이미지는 우리가 IMAGE_PATH 대신 image_full_url 또는 캐시 키와 비즈니스 컨텍스트에서 image_id를 사용하여 생각의 시간

이 지남에 따라 변경 것 signing_key의 PARAM이있는 경우 우리는 어떻게해야합니까. 우리에게이 능력을 줄 수있는 도서관을 찾지 못했지만.

내 질문은 : 변경 가능한 이미지 URL 캐시를 어떻게 처리 할 수 ​​있습니까? 권장 라이브러리가 있습니까?

감사!

답변

0

시도 react-native-cached-image. 쿼리 매개 변수를 무시하도록 지정할 수 있습니다.

type ImageCacheManagerOptions = { 
    headers: PropTypes.object,      // an object to be used as the headers when sending the request for the url. default {} 

    ttl: PropTypes.number,       // the number of seconds each url will stay in the cache. default 2 weeks 

    useQueryParamsInCacheKey: PropTypes.oneOfType([ // when handling a URL with query params, this indicates how it should be treated: 
    PropTypes.bool,        // if a bool value is given the whole query string will be used/ignored 
    PropTypes.arrayOf(PropTypes.string)   // if an array of strings is given, only these keys will be taken from the query string. 
    ]),            // default false 

    cacheLocation: PropTypes.string,    // the path to the root of the cache folder. default the device cache dir 

    allowSelfSignedSSL: PropTypes.bool,    // true to allow self signed SSL URLs to be downloaded. default false 
};