From f3079281b424a4ccc9ceaf562e3263d4eaff8433 Mon Sep 17 00:00:00 2001 From: Tai Nguyen Bui Date: Mon, 25 Nov 2019 16:43:31 +0000 Subject: [PATCH 1/2] fixes issue with 404 errors when retrieving original format for files that have not been ingested --- package.json | 2 +- src/dataverseClient.ts | 2 +- test/dataverseClient.spec.ts | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3d7eb2d8..3f47c559 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-dataverse", - "version": "1.0.39", + "version": "1.0.40", "description": "A Dataverse module for JavaScript/TypeScript", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/dataverseClient.ts b/src/dataverseClient.ts index 696663c6..5e4570ec 100644 --- a/src/dataverseClient.ts +++ b/src/dataverseClient.ts @@ -58,7 +58,7 @@ export class DataverseClient { }) } - public async getFile(fileId: string, getOriginal = true): Promise { + public async getFile(fileId: string, getOriginal = false): Promise { const url = `${this.host}/api/access/datafile/${fileId}${getOriginal ? '?format=original' : ''}` return this.getRequest(url, { headers: this.getHeaders(), diff --git a/test/dataverseClient.spec.ts b/test/dataverseClient.spec.ts index a28c80ac..e9e6dae1 100644 --- a/test/dataverseClient.spec.ts +++ b/test/dataverseClient.spec.ts @@ -434,20 +434,20 @@ describe('DataverseClient', () => { await client.getFile(fileId) assert.calledOnce(axiosGetStub) - assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}?format=original`, { + assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}`, { headers: { 'X-Dataverse-key': apiToken }, responseType: 'arraybuffer' }) }) - describe('get ingested file', () => { + describe('get original file', () => { it('should call axios with expected url', async () => { const fileId: string = random.number().toString() - await client.getFile(fileId, false) + await client.getFile(fileId, true) assert.calledOnce(axiosGetStub) - assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}`, { + assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}?format=original`, { headers: { 'X-Dataverse-key': apiToken }, responseType: 'arraybuffer' }) @@ -461,7 +461,7 @@ describe('DataverseClient', () => { await client.getFile(fileId) assert.calledOnce(axiosGetStub) - assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}?format=original`, { + assert.calledWithExactly(axiosGetStub, `${host}/api/access/datafile/${fileId}`, { headers: { 'X-Dataverse-key': '' }, responseType: 'arraybuffer' }) @@ -475,7 +475,7 @@ describe('DataverseClient', () => { 'test': randomValue } axiosGetStub - .withArgs(`${host}/api/access/datafile/${fileId}?format=original`, { + .withArgs(`${host}/api/access/datafile/${fileId}`, { headers: { 'X-Dataverse-key': apiToken }, responseType: 'arraybuffer' }) From 118c59aa2fbdbe6d68fbb5da680614fa49fee192 Mon Sep 17 00:00:00 2001 From: Tai Nguyen Bui Date: Mon, 30 Dec 2019 08:34:11 +0000 Subject: [PATCH 2/2] 1.0.41 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f47c559..b9e1538a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-dataverse", - "version": "1.0.40", + "version": "1.0.41", "description": "A Dataverse module for JavaScript/TypeScript", "main": "./dist/index.js", "types": "./dist/index.d.ts",