Skip to content
Snippets Groups Projects
Commit 888bbdb0 authored by Igor Markin's avatar Igor Markin
Browse files

Merge branch '4-investigate-issue-with-the-caching-of-files-in-backblaze' into 'master'

Resolve "Investigate issue with the caching of files in backblaze"

See merge request !77
parents 429acbff e40b28ec
No related branches found
No related tags found
1 merge request!77Resolve "Investigate issue with the caching of files in backblaze"
Pipeline #43935 passed
...@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. ...@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [2.0.1] - 2021-06-23
### Changed
- Removed a hack that adds random number to the Backblaze query in order to reset cache
## [2.0.0] - 2021-06-15 ## [2.0.0] - 2021-06-15
### Removed ### Removed
......
...@@ -32,10 +32,7 @@ class CloudflareService { ...@@ -32,10 +32,7 @@ class CloudflareService {
} }
fetchFile(fileName, bucket = this._defaultBucket) { fetchFile(fileName, bucket = this._defaultBucket) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// v?= is a dirty fix to prevent caching of the CORS error response in case file is missing. const response = yield axios_1.default(`${this._cdnUrl}/file/${bucket}/${fileName}`);
// Because of browser caching CORS error in case of missing file, it's not possible to retrieve it when it's being uploaded.
// Dig into https://www.backblaze.com/b2/docs/cors_rules.html and fix
const response = yield axios_1.default(`${this._cdnUrl}/file/${bucket}/${fileName}?v=${Math.random()}`);
const data = response.data; const data = response.data;
const uploadTime = response.headers["x-bz-upload-timestamp"] const uploadTime = response.headers["x-bz-upload-timestamp"]
? parseInt(response.headers["x-bz-upload-timestamp"]) ? parseInt(response.headers["x-bz-upload-timestamp"])
......
{ {
"name": "@vereign/light-utils", "name": "@vereign/light-utils",
"version": "2.0.0", "version": "2.0.1",
"license": "MIT", "license": "MIT",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
......
...@@ -34,12 +34,7 @@ class CloudflareService { ...@@ -34,12 +34,7 @@ class CloudflareService {
fileName: string, fileName: string,
bucket = this._defaultBucket bucket = this._defaultBucket
): Promise<{ data: T; uploadTime: number }> { ): Promise<{ data: T; uploadTime: number }> {
// v?= is a dirty fix to prevent caching of the CORS error response in case file is missing. const response = await axios(`${this._cdnUrl}/file/${bucket}/${fileName}`);
// Because of browser caching CORS error in case of missing file, it's not possible to retrieve it when it's being uploaded.
// Dig into https://www.backblaze.com/b2/docs/cors_rules.html and fix
const response = await axios(
`${this._cdnUrl}/file/${bucket}/${fileName}?v=${Math.random()}`
);
const data = response.data as T; const data = response.data as T;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment