Skip to content

Commit

Permalink
[docs][xs]: Add documentation for pushBlob() function - #4
Browse files Browse the repository at this point in the history
  • Loading branch information
kmanaseryan committed Sep 15, 2020
1 parent bd23970 commit 5ce75cc
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class Client {
let scope = [`obj:${this.organizationId}/${this.datasetId}/*:write`]

// Get the JWT token from CkanAuthz, the user should provide the url
const response = await CkanAuthApi.getJWTFromCkanAuthz(
this.api,
this.apiKey,
scope
)
return response.result.token
const response = await CkanAuthApi.getJWTFromCkanAuthz(
this.api,
this.apiKey,
scope
)
return response.result.token
}

/**
Expand Down Expand Up @@ -94,8 +94,18 @@ class Client {
}

/**
* @param {File} file
* The result of push blob method
* @typedef {Object} PushBlobResult
* @property {string} oid - oid
* @property {number} size - size of the file
* @property {string} name - resource name
* @property {boolean} success - Indicates whether the request was successful or not
* @property {boolean} fileExists - Indicates whether the resource exists or not
*/
/**
* @param {Object} resource - This datajs resource. Please check https://github.com/datopian/data.js
* @param {function} onProgress a callback function to track the progress
* @return {Promise<PushBlobResult>} request result
*/
async pushBlob(resource, onProgress) {
// Get the JWT token
Expand Down Expand Up @@ -128,7 +138,11 @@ class Client {
resourceContent,
onProgress
)
await CkanUploadAPI.verifyUpload(lfs.objects[0].actions.verify, resource.hash, resource.size)
await CkanUploadAPI.verifyUpload(
lfs.objects[0].actions.verify,
resource.hash,
resource.size
)
return result
} else {
// File is already in storage
Expand Down

0 comments on commit 5ce75cc

Please sign in to comment.