Skip to content

Commit 6446b96

Browse files
author
Ben Stahl
committed
Keep consistent with file id
1 parent 880dafa commit 6446b96

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

lib/handlers/HeadHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class HeadHandler extends BaseHandler {
1717
return super.send(res, 404);
1818
}
1919

20-
const file_name = match[1];
21-
return this.store.getOffset(file_name)
20+
const file_id = match[1];
21+
return this.store.getOffset(file_id)
2222
.then((file) => {
2323
// The Server MUST prevent the client and/or proxies from
2424
// caching the response by adding the Cache-Control: no-store

lib/handlers/PatchHandler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PatchHandler extends BaseHandler {
1616
if (!match) {
1717
return super.send(res, 404);
1818
}
19-
const file_name = match[1];
19+
const file_id = match[1];
2020

2121
const content_type = req.headers['content-type'];
2222
// All PATCH requests MUST use Content-Type: application/offset+octet-stream.
@@ -33,15 +33,15 @@ class PatchHandler extends BaseHandler {
3333
return super.send(res, 403);
3434
}
3535

36-
return this.store.getOffset(file_name)
36+
return this.store.getOffset(file_id)
3737
.then((stats) => {
3838
if (stats.size !== offset) {
3939
// If the offsets do not match, the Server MUST respond with the 409 Conflict status without modifying the upload resource.
4040
console.warn(`[PatchHandler] send: Incorrect offset - ${offset} sent but file is ${stats.size}`);
4141
return Promise.reject(409);
4242
}
4343

44-
return this.store.write(req, file_name, offset);
44+
return this.store.write(req, file_id, offset);
4545
})
4646
.then((new_offset) => {
4747
// It MUST include the Upload-Offset header containing the new offset.

lib/stores/GCSDataStore.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ class GCSDataStore extends DataStore {
7676
* https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.32.0/storage/file?method=createWriteStream
7777
*
7878
* @param {[type]} req [description]
79-
* @param {[type]} file_name [description]
79+
* @param {[type]} file_id [description]
8080
* @param {[type]} offset [description]
8181
* @return {[type]} [description]
8282
*/
83-
write(req, file_name, offset) {
83+
write(req, file_id, offset) {
8484
return new Promise((resolve, reject) => {
85-
const path = `https://storage.googleapis.com/${this.bucket.name}/${file_name}`;
86-
const file = this.bucket.file(file_name);
85+
const path = `https://storage.googleapis.com/${this.bucket.name}/${file_id}`;
86+
const file = this.bucket.file(file_id);
8787
const stream = file.createWriteStream();
8888

8989
if (!stream) {
@@ -113,14 +113,14 @@ class GCSDataStore extends DataStore {
113113
* Make a metadata request for a file in GCS.
114114
* https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.32.0/storage/file?method=getMetadata
115115
*
116-
* @param {[type]} file_name [description]
116+
* @param {[type]} file_id [description]
117117
* @return {[type]} [description]
118118
*/
119-
getOffset(file_name) {
120-
super.getOffset(file_name);
119+
getOffset(file_id) {
120+
super.getOffset(file_id);
121121

122122
return new Promise((resolve, reject) => {
123-
const file = this.bucket.file(file_name);
123+
const file = this.bucket.file(file_id);
124124
file.getMetadata((error, metadata, apiResponse) => {
125125
if (error) {
126126
console.log(error);

0 commit comments

Comments
 (0)