Skip to content

Commit

Permalink
Added: method docs to AddUploadedFileToDataset and UploadFile use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Jun 10, 2024
1 parent f6360fb commit 081c8bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/files/domain/useCases/AddUploadedFileToDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ export class AddUploadedFileToDataset implements UseCase<void> {
}

/**
* TODO
* @returns {Promise<void>}
* Adds a file that has been uploaded to remote storage to the dataset.
*
* This method completes the flow initiated by the UploadFile use case, which involves adding the uploaded file to the specified dataset.
* (https://guides.dataverse.org/en/latest/developers/s3-direct-upload-api.html#adding-the-uploaded-file-to-the-dataset)
*
* Note: This use case can be used independently of the UploadFile use case, e.g., supporting scenarios in which the file already exists in S3 or has been uploaded via some out-of-band method.
*
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers) or a number (for numeric identifiers).
* @param {File} [file] - The file object that has been uploaded.
* @param {string} [storageId] - The storage identifier associated with the uploaded file.
* @returns {Promise<void>} A promise that resolves when the file has been successfully added to the dataset.
*
*/
async execute(datasetId: number | string, file: File, storageId: string): Promise<void> {
await this.directUploadClient.addUploadedFileToDataset(datasetId, file, storageId)
Expand Down
14 changes: 12 additions & 2 deletions src/files/domain/useCases/UploadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ export class UploadFile implements UseCase<string> {
}

/**
* TODO
* @returns {Promise<string>}
* Uploads a file to remote storage and returns the storage identifier.
*
* This use case is based on the Direct Upload API, particularly the first part of the flow, "Requesting Direct Upload of a DataFile".
* To fulfill the flow, you will need to call the AddUploadedFileToDataset Use Case to add the uploaded file to the dataset.
* (https://guides.dataverse.org/en/latest/developers/s3-direct-upload-api.html#requesting-direct-upload-of-a-datafile)
*
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers) or a number (for numeric identifiers).
* @param {File} [file] - The file object to be uploaded.
* @param {function(number): void} [progress] - A callback function to monitor the upload progress, receiving the current progress as a number.
* @param {AbortController} [abortController] - An AbortController to manage and abort the upload process if necessary.
* @returns {Promise<string>} A promise that resolves to the storage identifier of the uploaded file.
*
*/
async execute(
datasetId: number | string,
Expand Down

0 comments on commit 081c8bf

Please sign in to comment.