Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Add spaces path handler and allow responseType for getFileContents op…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
JanAckermann committed Jan 26, 2022
1 parent 30f23b9 commit a19394f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/fileManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ class Files {

_sanitizePath (path) {
path = path || ''

if (path.startsWith('spaces/')) {
return path
}

// Remove leading slash if present
path = path.startsWith('/') ? path.substr(1) : path
return '/files/' + this.helpers.getCurrentUser().id + '/' + path
Expand Down
17 changes: 14 additions & 3 deletions src/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class helpers {
if (user !== null) {
return Promise.resolve(user)
}

return this._updateCurrentUser()
}

Expand Down Expand Up @@ -344,9 +343,21 @@ class helpers {
})
.then(async res => {
res.statusCode = res.status
resolve({

let body

switch (options.responseType) {
case 'arrayBuffer':
body = await res.arrayBuffer()
break

default:
body = await res.text()
}

return resolve({
response: res,
body: await res.text()
body
})
})
})
Expand Down

0 comments on commit a19394f

Please sign in to comment.