@robinpath/box
0.1.2Node.jsPublicBox module for RobinPath.
Box
Box module for RobinPath.
Package: @robinpath/box | Category: Cloud Storage | Type: Integration
Authentication
box.setCredentials "your-credentials"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the box module when you need to:
- listFolderItems -- Use
box.listFolderItemsto perform this operation - getFolderInfo -- Use
box.getFolderInfoto perform this operation - createFolder -- Use
box.createFolderto perform this operation - deleteFolder -- Use
box.deleteFolderto perform this operation - getFileInfo -- Use
box.getFileInfoto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure box credentials. | object |
listFolderItems | listFolderItems | object |
getFolderInfo | getFolderInfo | object |
createFolder | createFolder | object |
deleteFolder | deleteFolder | object |
getFileInfo | getFileInfo | object |
downloadFile | downloadFile | object |
deleteFile | deleteFile | object |
copyFile | copyFile | object |
moveFile | moveFile | object |
uploadFile | uploadFile | object |
searchContent | searchContent | object |
createSharedLink | createSharedLink | object |
getSharedLink | getSharedLink | object |
listCollaborations | listCollaborations | object |
addCollaboration | addCollaboration | object |
getUser | getUser | object |
updateFileInfo | updateFileInfo | object |
lockFile | lockFile | object |
Functions
setCredentials
Configure box credentials.
Module: box | Returns: object -- API response.
box.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | accessToken |
listFolderItems
listFolderItems
Module: box | Returns: object -- API response.
box.listFolderItems
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getFolderInfo
getFolderInfo
Module: box | Returns: object -- API response.
box.getFolderInfo
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createFolder
createFolder
Module: box | Returns: object -- API response.
box.createFolder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
deleteFolder
deleteFolder
Module: box | Returns: object -- API response.
box.deleteFolder
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getFileInfo
getFileInfo
Module: box | Returns: object -- API response.
box.getFileInfo
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
downloadFile
downloadFile
Module: box | Returns: object -- API response.
box.downloadFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
deleteFile
deleteFile
Module: box | Returns: object -- API response.
box.deleteFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
copyFile
copyFile
Module: box | Returns: object -- API response.
box.copyFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
moveFile
moveFile
Module: box | Returns: object -- API response.
box.moveFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
uploadFile
uploadFile
Module: box | Returns: object -- API response.
box.uploadFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
searchContent
searchContent
Module: box | Returns: object -- API response.
box.searchContent
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createSharedLink
createSharedLink
Module: box | Returns: object -- API response.
box.createSharedLink
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getSharedLink
getSharedLink
Module: box | Returns: object -- API response.
box.getSharedLink
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listCollaborations
listCollaborations
Module: box | Returns: object -- API response.
box.listCollaborations
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
addCollaboration
addCollaboration
Module: box | Returns: object -- API response.
box.addCollaboration
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getUser
getUser
Module: box | Returns: object -- API response.
box.getUser
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateFileInfo
updateFileInfo
Module: box | Returns: object -- API response.
box.updateFileInfo
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
lockFile
lockFile
Module: box | Returns: object -- API response.
box.lockFile
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
Box API error (${res.status}): ${t} | Check the error message for details |
box.setCredentials requires accessToken. | Check the error message for details |
box.deleteFolder requires an ID. | Check the error message for details |
box.deleteFile requires an ID. | Check the error message for details |
box.copyFile requires an ID. | Check the error message for details |
box.moveFile requires an ID. | Check the error message for details |
box.updateFileInfo requires an ID. | Check the error message for details |
box.lockFile requires an ID. | Check the error message for details |
@desc "List folder items and validate result"
do
set $result as box.listFolderItems
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate FolderItems
Retrieve all items and loop through them.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "List folder items and iterate results"
do
set $result as box.listFolderItems
each $item in $result
print $item
end
enddo
2. Create a new item with createFolder
Create a new resource and capture the result.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "Create folder"
do
set $result as box.createFolder
print "Created: " + $result
enddo
3. Create and update workflow
Create an item and then update it.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "Create folder and update file info"
do
set $created as box.createFolder
# Update the created item
box.updateFileInfo
enddo
4. Check before creating
List existing items and only create if needed.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "List folder items and create folder"
do
set $existing as box.listFolderItems
if $existing == null
box.createFolder
print "Item created"
else
print "Item already exists"
end
enddo
5. Multi-step Box workflow
Chain multiple box operations together.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "List folder items, get folder info, and more"
do
set $r_listFolderItems as box.listFolderItems
set $r_getFolderInfo as box.getFolderInfo
set $r_createFolder as box.createFolder
print "All operations complete"
enddo
6. Safe listFolderItems with validation
Check results before proceeding.
@desc "Setup authentication"
do
box.setCredentials $token
enddo
@desc "List folder items and validate result"
do
set $result as box.listFolderItems
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- s3 -- Amazon S3 module for complementary functionality
- dropbox -- Dropbox module for complementary functionality
- onedrive -- OneDrive module for complementary functionality
- google-drive -- Google Drive module for complementary functionality
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.2 | latest | 1 months ago |
Related Modules
github
JS@robinpathv0.1.1
GitHub module for RobinPath.
bitbucket
JS@robinpathv0.1.2
Bitbucket module for RobinPath.
cache
JS@robinpathv0.1.2
In-memory key-value cache with optional TTL expiration for temporary data storage
cloudflare
JS@robinpathv0.1.2
Cloudflare module for RobinPath.
$ robinpath add @robinpath/box
