This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Readme and JSDocs to the filestore-client (#179)
* Add jsdocs * add readme
- Loading branch information
Showing
6 changed files
with
137 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
# RainCatcher FileStore client | ||
|
||
WIP | ||
RainCatcher FileStore Client provides a manager which provides the support for: | ||
- Downloading files from a server. | ||
- Uploading files from a mobile device to a server. | ||
|
||
## Usage | ||
1. Implement the [HttpClient](./src/HttpClient.ts) Interface | ||
|
||
2. Import FileManager | ||
```javascript | ||
var FileManager = require('@raincatcher/filestore-client').FileManager; | ||
... | ||
var fileManager = new FileManager(serverUrl, fileQueueName, httpClient); | ||
``` | ||
|
||
3. Use the FileManager for uploading/downloading files to and from the server. | ||
```javascript | ||
fileManager.scheduleFileToBeUploaded(fileQueueEntry); | ||
fileManager.scheduleFileToBeDownloaded(fileQueueEntry); | ||
``` | ||
- Ensure the fileQueueEntry adheres to the [FileQueueEntry](./src/FileQueueEntry.ts) interface. | ||
|
||
## HttpClient Interface | ||
The [HttpClient](./src/HttpClient.ts) interface should be implemented in order to enable the FileStore client to make network requests for uploading and downloading files to and from a server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
/** | ||
* Contains required fields required to save file | ||
* Contains fields required for uploading and downloading a file. | ||
*/ | ||
export interface FileQueueEntry { | ||
/** | ||
* Uri to local filesystem containing file | ||
* File URI to local filesystem containing the file. | ||
*/ | ||
uri: string; | ||
|
||
/** | ||
* File type | ||
*/ | ||
type: 'uri'|'base64'; | ||
|
||
/** | ||
* File identifier | ||
*/ | ||
id?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import * as Promise from 'bluebird'; | ||
|
||
/** | ||
* Interface for making network requests for uploading and downloading files from a server. | ||
*/ | ||
export interface HttpClient { | ||
/** | ||
* Upload a file to the server. | ||
* | ||
* @param url - URL to the file endpoint in the server. | ||
* @param data - Data containing the files and other metadata to be uploaded to the server. | ||
*/ | ||
upload: (url: string, data: FormData) => Promise<Response>; | ||
|
||
/** | ||
* Download a file from the server. | ||
* | ||
* @param url - URL to the file endpoint in the server | ||
*/ | ||
download: (url: string) => Promise<Response>; | ||
} |