- Source:
Methods for files.
Methods
(static) deleteByKey(externalKey) → {Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>}
- Source:
- Since:
- 1.0.0
Deletes a file, where externalKey
specifies the File ID of the file to be deleted.
Example
// delete the file with File ID of 'f729e367-55f8-42e7-ac7c-a9c9a8a8912e'
const caspio = require('caspio-sdk')(caspioCredentials);
async function deleteFile() {
const FILE_ID = 'f729e367-55f8-42e7-ac7c-a9c9a8a8912e';
const deleteResult = await caspio.files.deleteByKey(FILE_ID);
console.log(deleteResult);
return deleteResult;
}
deleteFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: 'File successfully deleted.'
}
Parameters:
Name | Type | Description |
---|---|---|
externalKey |
string | File ID |
Returns:
Object with information about the attempted file deletion (i.e., status
, statusText
, and message
).
- Type
- Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>
(static) deleteByPath(filePath) → {Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>}
- Source:
- Since:
- 1.0.0
Deletes a file, where filePath
specifies the location of the file to be deleted.
Example
// deletes file with full path of '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/somefile1.png'
const caspio = require('caspio-sdk')(caspioCredentials);
async function deleteFile() {
const FILE_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/somefile1.png';
const deleteResult = await caspio.files.deleteByPath(FILE_PATH);
console.log(deleteResult);
return deleteResult;
}
deleteFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: "File 'somefile1.png' successfully deleted."
}
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string | Path to file |
Returns:
Object with information about the attempted file deletion (i.e., status
, statusText
, and message
).
- Type
- Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>
(static) downloadByKey(externalKey, saveAsWithoutExtopt) → {Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>}
- Source:
- Since:
- 1.0.0
Downloads file content as an attachment, where externalKey
specifies the File ID of the file to be downloaded and saveAsWithoutExt
, if provided, specifies what the file's name should be upon download (the default name is that of the file being downloaded).
Example
// download file with File ID of 'f729e367-55f8-42e7-ac7c-a9c9a8a8912e'
// and save as '/Users/someuser/Desktop/myFile.<extension-of-downloaded-file>'
const caspio = require('caspio-sdk')(caspioCredentials);
async function downloadFile() {
const FILE_ID = 'f729e367-55f8-42e7-ac7c-a9c9a8a8912e';
const SAVE_AS = '/Users/someuser/Desktop/myFile';
const downloadResult = await caspio.files.downloadByKey(FILE_ID, SAVE_AS);
console.log(downloadResult);
return downloadResult;
}
downloadFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: "File '/Users/someuser/Desktop/myFile.png' successfully downloaded."
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
externalKey |
string | File ID |
||
saveAsWithoutExt |
string |
<optional> |
''
|
Name to save file as (the extension should not be specified as this will be deduced by the content type of the file during download). If this argument is not provided, then the original file name is used. |
Returns:
Object with information about the attempted file download (i.e., status
, statusText
, and message
).
- Type
- Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>
(static) downloadByPath(filePath, saveAsWithoutExtopt) → {Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>}
- Source:
- Since:
- 1.0.0
Downloads file content as an attachment, where filePath
specifies the location of the file to be downloaded and saveAsWithoutExt
, if provided, specifies what the file's name should be upon download (the default name is that of the file being downloaded).
Example
// download file '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/somefile2.png'
// and save as '/Users/someuser/Desktop/myFile.png'
const caspio = require('caspio-sdk')(caspioCredentials);
async function downloadFile() {
const FILE_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/somefile2.png';
const SAVE_AS = '/Users/someuser/Desktop/myFile';
const downloadResult = await caspio.files.downloadByPath(FILE_PATH, SAVE_AS);
console.log(downloadResult);
return downloadResult;
}
downloadFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: "File '/Users/someuser/Desktop/myFile.png' successfully downloaded."
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filePath |
string | Path to file |
||
saveAsWithoutExt |
string |
<optional> |
''
|
Name to save file as (the extension should not be specified as this will be deduced by the content type of the file during download). If this argument is not provided, then the original file name is used. |
Returns:
Object with information about the attempted file download (i.e., status
, statusText
, and message
).
- Type
- Promise.<{status: (200|403|404), statusText: ('OK'|'Forbidden'|'NotFound'), message: string}>
(static) metadataByKey(externalKeyopt) → {Promise.<{Folders: Array.<{Name: string, ExternalKey: string, ContentType: string, DateCreated: string}>, Files: Array.<{Name: string, ExternalKey: string, Size: number, LastModified: string, ContentType: string, DateCreated: string}>}>}
- Source:
- Since:
- 1.0.0
Returns metadata for file(s) and folder(s) based on the externalKey
provided. Specifically, returns an object with Folders
and Files
as keys whose values are arrays whose elements are metadata objects concerning those folders or files, respectively.
If externalKey
is empty (i.e., the default value), then the list of files and folders of the root folder is returned.
If externalKey
belongs to a folder, then the list of files and folders from the specified folder is returned.
If externalKey
belongs to a file, then an object of the form { "Folders": [], "Files": [ {...} ] }
is returned, where { ... }
refers to the single file identified by externalKey
.
Example
// get the files and folders in the 'Demo_Sandbox' folder
const caspio = require('caspio-sdk')(caspioCredentials);
async function getFolderMetadata() {
// the key below is for the 'Demo_Sandbox' folder
const FILE_FOLDER_ID = "c5b7f134-dcd0-4c34-bba3-34129ee6e9eb";
const metadata = await caspio.files.metadataByKey(FILE_FOLDER_ID);
console.log(metadata);
return metadata;
}
getFolderMetadata();
// sample return value
{
Folders: [
{
Name: 'Demo_Subfolder_One',
ExternalKey: '4e2ed81b-b9af-4116-852f-c7cc29cda6a1',
ContentType: 'caspio/folder',
DateCreated: '1/12/2022 7:14:50 AM'
},
{
Name: 'Demo_Subfolder_Two',
ExternalKey: '86eccfcc-e295-405f-978c-3e06495b3d82',
ContentType: 'caspio/folder',
DateCreated: '1/12/2022 7:14:01 AM'
}
],
Files: [
{
Name: 'ds1.png',
ExternalKey: 'b0bd9207-06e2-4932-8c1a-97aff5c93ae5',
Size: 1449,
LastModified: '1/28/2022 3:31:03 PM',
ContentType: 'image/png',
DateCreated: '1/12/2022 7:16:58 AM'
}
]
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
externalKey |
string |
<optional> |
''
|
Folder or file ID |
Returns:
Object with metadata concerning folders and files
- Type
- Promise.<{Folders: Array.<{Name: string, ExternalKey: string, ContentType: string, DateCreated: string}>, Files: Array.<{Name: string, ExternalKey: string, Size: number, LastModified: string, ContentType: string, DateCreated: string}>}>
(static) metadataByPath(resourcePath, optionsopt) → {Promise.<({Name: string, ExternalKey: string, ContentType: string, DateCreated: string}|{Name: string, ExternalKey: string, Size: number, LastModified: string, ContentType: string, DateCreated: string})>}
- Source:
- Since:
- 1.0.0
Returns metadata specifically for a file or directory by path, resourcePath
(i.e., instead of by a file or directory key). By default, metadata is requested for a file. This can be changed, however, by setting the resourceType
property of the options
object to 'd'
for directory (the default is 'f'
for file).
Examples
// Get metadata for the '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder' directory
const caspio = require('caspio-sdk')(caspioCredentials);
async function getDirectoryMetadata() {
const DIRECTORY_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder';
const metadata = await caspio.files.metadataByPath(DIRECTORY_PATH, { resourceType: 'd' });
console.log(metadata);
return metadata;
}
getDirectoryMetadata();
// sample return value
{
Name: 'Demo_Subfolder_One_Subfolder',
ExternalKey: '6b8dc1eb-8c38-4512-8040-8a847e478778',
ContentType: 'caspio/folder',
DateCreated: '1/12/2022 7:15:18 AM'
}
// Get metadata for the '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/dsos1.png' file
const caspio = require('caspio-sdk')(caspioCredentials);
async function getFileMetadata() {
const FILE_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder/dsos1.png';
const metadata = await caspio.files.metadataByPath(FILE_PATH, { resourceType: 'f' });
console.log(metadata);
return metadata;
}
getFileMetadata();
// sample return value
{
Name: 'dsos1.png',
ExternalKey: 'c92e471f-8cd1-49ce-b5d5-2c88bf0ab045',
Size: 1449,
LastModified: '1/28/2022 3:31:42 PM',
ContentType: 'image/png',
DateCreated: '1/24/2022 8:30:51 PM'
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resourcePath |
string | Path to requested resource such as |
||
options |
object |
<optional> |
{ 'resourceType': 'f' }
|
Object with a |
Returns:
An object with metadata strictly about the requested resource; that is, if { 'resourceType': 'f' }
is supplied as the options
argument, which is the default, then metadata about a file will be returned (if found).
Similarly, if { 'resourceType': 'd' }
is supplied as the options
argument, then metadata about a directory or folder will be returned (if found).
- Type
- Promise.<({Name: string, ExternalKey: string, ContentType: string, DateCreated: string}|{Name: string, ExternalKey: string, Size: number, LastModified: string, ContentType: string, DateCreated: string})>
(static) uploadByKey(srcFilePathsArr, externalKeyopt) → {Promise.<{status: 201, statusText: 'Created', message: string, uploadedFiles: Array.<{Name: string, ExternalKey: string}>}>}
- Source:
- Since:
- 1.0.0
Uploads one or more files into the Files area of a Caspio account. Specifically, an array of one or more elements (i.e., srcFilePathsArr
) is specified as the file(s) to be uploaded, where externalKey
specifies the Folder ID of the directory where files should be uploaded.
Examples
// upload multiple files to a directory where original and new names are used for the uploaded files
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadFiles() {
const FOLDER_ID = '6b8dc1eb-8c38-4512-8040-8a847e478778';
const FILES_ARRAY = ['./somefile1.png', ['./somefile2.png', 'myCoolSecondFile'], './somefile3.png'];
const uploadResult = await caspio.files.uploadByKey(FILES_ARRAY, FOLDER_ID);
console.log(uploadResult);
return uploadResult;
}
uploadFiles();
// sample return value
{
status: 201,
statusText: 'Created',
message: 'File(s) uploaded successfully, in part or in whole. If a file was not uploaded, then a file with the same name already exists in the specified location.',
uploadedFiles: [
{
Name: 'somefile1.png',
ExternalKey: '8337a0b4-e314-4e82-a0ee-4ea2e1e8b38b'
},
{
Name: 'myCoolSecondFile.png',
ExternalKey: 'ab9c2d44-71a4-4218-977d-62aedc21bb53'
},
{
Name: 'somefile3.png',
ExternalKey: '452d659c-319c-4ebc-95f1-a2a49cc6a97a'
}
]
}
// attempt upload of multiple files to a directory resulting in only one file being uploaded
// since the other two files already exist in the same location by the same name
// (assumes example above was used prior to this example)
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadFiles() {
const FOLDER_ID = '6b8dc1eb-8c38-4512-8040-8a847e478778';
const FILES_ARRAY = ['./somefile1.png', './somefile2.png', './somefile3.png'];
const uploadResult = await caspio.files.uploadByKey(FILES_ARRAY, FOLDER_ID);
console.log(uploadResult);
return uploadResult;
}
uploadFiles();
// sample return value
{
status: 201,
statusText: 'Created',
message: 'File(s) uploaded successfully, in part or in whole. If a file was not uploaded, then a file with the same name already exists in the specified location.',
uploadedFiles: [
{
Name: 'somefile2.png',
ExternalKey: 'f9d70ed7-1cce-425b-87b7-914a743da5af'
}
]
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srcFilePathsArr |
Array.<(string|Array.<string, string>)> | An array consisting of strings and/or 2-element subarrays. If the element is a string, then the element should be the path to the file to be uploaded (i.e., where the name of the uploaded file will be the name of the original file); if, however, the element is a 2-element array, the first element should be the file path to the file to be uploaded, and the second element should be the new name of the file without an extension (sort of like a "Save As"), where the extension is deduced from the first element of the 2-element array. Example argument: If an attempt is made to upload a file with the same name as a currently existing file, then this attempt is aborted. If all attempts are aborted, then the Caspio server throws an error. |
||
externalKey |
string |
<optional> |
''
|
Upload destination by key (i.e., the ID of the destination folder). If |
Returns:
Object with information about the attempted file(s) upload to the folder specified by externalKey
(i.e., status
, statusText
, message
, and uploadedFiles
).
- Type
- Promise.<{status: 201, statusText: 'Created', message: string, uploadedFiles: Array.<{Name: string, ExternalKey: string}>}>
(static) uploadByPath(srcFilePathsArr, destDirPathopt) → {Promise.<{status: 201, statusText: 'Created', message: string, uploadedFiles: Array.<{Name: string, ExternalKey: string}>}>}
- Source:
- Since:
- 1.0.0
Uploads one or more files into the Files area of a Caspio account. Specifically, an array of one or more elements (i.e., srcFilePathsArr
) is specified as the file(s) to be uploaded, where destDirPath
specifies the path to the directory where files should be uploaded.
Examples
// upload multiple files to a directory where original and new names are used for the uploaded files
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadFiles() {
const FOLDER_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder';
const FILES_ARRAY = ['./somefile1.png', ['./somefile2.png', 'myCoolSecondFile'], './somefile3.png'];
const uploadResult = await caspio.files.uploadByPath(FILES_ARRAY, FOLDER_PATH);
console.log(uploadResult);
return uploadResult;
}
uploadFiles();
// sample return value
{
status: 201,
statusText: 'Created',
message: 'File(s) uploaded successfully, in part or in whole. If a file was not uploaded, then a file with the same name already exists in the specified location.',
uploadedFiles: [
{
Name: 'somefile1.png',
ExternalKey: '2098314a-7a3d-4721-aa87-42f72dfce8b9'
},
{
Name: 'myCoolSecondFile.png',
ExternalKey: '06d55aaa-86e3-4392-a052-6def82380a77'
},
{
Name: 'somefile3.png',
ExternalKey: '070e2b77-efca-4ba5-b3e8-7868dd3d2091'
}
]
}
// attempt upload of multiple files to a directory resulting in only one file being uploaded
// since the other two files already exist in the same location by the same name
// (assumes example above was used prior to this example)
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadFiles() {
const FOLDER_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder';
const FILES_ARRAY = ['./somefile1.png', './somefile2.png', './somefile3.png'];
const uploadResult = await caspio.files.uploadByPath(FILES_ARRAY, FOLDER_PATH);
console.log(uploadResult);
return uploadResult;
}
uploadFiles();
// sample return value
{
status: 201,
statusText: 'Created',
message: 'File(s) uploaded successfully, in part or in whole. If a file was not uploaded, then a file with the same name already exists in the specified location.',
uploadedFiles: [
{
Name: 'somefile2.png',
ExternalKey: 'f729e367-55f8-42e7-ac7c-a9c9a8a8912e'
}
]
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srcFilePathsArr |
Array.<(string|Array.<string, string>)> | An array consisting of strings and/or 2-element subarrays. If the element is a string, then the element should be the path to the file to be uploaded (i.e., where the name of the uploaded file will be the name of the original file); if, however, the element is a 2-element array, the first element should be the file path to the file to be uploaded, and the second element should be the new name of the file without an extension (sort of like a "Save As"), where the extension is deduced from the first element of the 2-element array. Example argument: If an attempt is made to upload a file with the same name as a currently existing file, then this attempt is aborted. If all attempts are aborted, then the Caspio server throws an error. |
||
destDirPath |
string |
<optional> |
''
|
Upload destination by path (i.e., the path of the destination folder). If |
Returns:
Object with information about the attempted file(s) upload to the folder specified by externalKey
(i.e., status
, statusText
, message
, and uploadedFiles
).
- Type
- Promise.<{status: 201, statusText: 'Created', message: string, uploadedFiles: Array.<{Name: string, ExternalKey: string}>}>
(static) uploadOverwriteByKey(srcFilePath, externalKeyopt, newFileNameNoExtopt) → {Promise.<{status: (200|201), statusText: ('OK'|'Created'), message: string, Name: string, ExternalKey: string}>}
- Source:
- Since:
- 1.0.0
Uploads or overwrites one file into the Caspio's account's Files area. A file is only overwritten if a file of the same name exists in the upload destination. The file to upload is specified by srcFilePath
, the destination of the upload directory as externalKey
(i.e., Folder ID of destination folder), and finally whether or not the original file name should be saved as a different file name upon upload, newFileNameNoExt
(by default, the original file name is used).
Examples
// upload the local file 'somefile1.png' to the Files area as 'dsos2.png' in the folder with
// a key of '6b8dc1eb-8c38-4512-8040-8a847e478778' (i.e., 'Demo_Subfolder_One_Subfolder')
// this results in creating a new file (i.e., no file is overwritten)
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadOrOverwriteFile() {
const FOLDER_ID = '6b8dc1eb-8c38-4512-8040-8a847e478778';
const uploadResult = await caspio.files.uploadOverwriteByKey('./somefile1.png', FOLDER_ID, 'dsos2');
console.log(uploadResult);
return uploadResult;
}
uploadOrOverwriteFile();
// sample return value
{
status: 201,
statusText: 'Created',
message: "File 'dsos2.png' uploaded successfully. No file was overwritten.",
Name: 'dsos2.png',
ExternalKey: '59f9f6d1-531d-460e-af57-458c2df2cfc6'
}
// upload the local file 'somefile2.png' to the Files area as 'dsos2.png' in the folder with
// a key of '6b8dc1eb-8c38-4512-8040-8a847e478778' (i.e., 'Demo_Subfolder_One_Subfolder')
// this results in overwriting the 'dsos2.png' file that was added in the previous example
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadOrOverwriteFile() {
const FOLDER_ID = '6b8dc1eb-8c38-4512-8040-8a847e478778';
const uploadResult = await caspio.files.uploadOverwriteByKey('./somefile2.png', FOLDER_ID, 'dsos2');
console.log(uploadResult);
return uploadResult;
}
uploadOrOverwriteFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: "File 'dsos2.png' uploaded successfully. Another file of the same name in the same location was overwritten.",
Name: 'dsos2.png',
ExternalKey: '59f9f6d1-531d-460e-af57-458c2df2cfc6'
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srcFilePath |
string | Path of the file to be uploaded |
||
externalKey |
string |
<optional> |
''
|
Upload destination by key (i.e., the ID of the destination folder). If |
newFileNameNoExt |
string |
<optional> |
''
|
New name for the file to be uploaded (almost like a "Save As" option). It should not contain the file extension--this will be deduced from the first argument, |
Returns:
Object with information about the upload attempt (i.e., status
, statusText
, message
, Name
, and ExternalKey
, where Name
represents the name of the uploaded file and ExternalKey
the file's assigned ID). If the status
value is 200
(with statusText
of 'OK'
), then a file of the same name in the same location was overwritten. If the status value is 201
(with statusText
of 'Created'
), then the file was uploaded without any other file being overwritten.
- Type
- Promise.<{status: (200|201), statusText: ('OK'|'Created'), message: string, Name: string, ExternalKey: string}>
(static) uploadOverwriteByPath(srcFilePath, destDirPathopt, newFileNameNoExtopt) → {Promise.<{status: (200|201), statusText: ('OK'|'Created'), message: string, Name: string, ExternalKey: string}>}
- Source:
- Since:
- 1.0.0
Uploads or overwrites one file into the Caspio's account's Files area. A file is only overwritten if a file of the same name exists in the upload destination. The file to upload is specified by srcFilePath
, the destination of the upload directory as destDirPath
, and finally whether or not the original file name should be saved as a different file name upon upload, newFileNameNoExt
(by default, the original file name is used).
Examples
// uploads a local file 'somefile2.png' to the Files area as 'dsos2.png' in the folder with
// full path '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder'
// this results in creating a new file (i.e., no file is overwritten)
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadOrOverwriteFile() {
const FOLDER_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder';
const uploadResult = await caspio.files.uploadOverwriteByPath('./somefile2.png', FOLDER_PATH, 'dsos2');
console.log(uploadResult);
return uploadResult;
}
uploadOrOverwriteFile();
// sample return value
{
status: 201,
statusText: 'Created',
message: "File 'dsos2.png' uploaded successfully. No file was overwritten.",
Name: 'dsos2.png',
ExternalKey: 'ad2c32c8-ae5a-41d9-885c-5f31f0d3a748'
}
// upload the local file 'somefile2.png' to the Files area as 'dsos2.png' in the folder with
// full path '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder'
// this results in overwriting the 'dsos2.png' file that was added in the previous example
const caspio = require('caspio-sdk')(caspioCredentials);
async function uploadOrOverwriteFile() {
const FOLDER_PATH = '/Demo_Sandbox/Demo_Subfolder_One/Demo_Subfolder_One_Subfolder';
const uploadResult = await caspio.files.uploadOverwriteByPath('./somefile2.png', FOLDER_PATH, 'dsos2');
console.log(uploadResult);
return uploadResult;
}
uploadOrOverwriteFile();
// sample return value
{
status: 200,
statusText: 'OK',
message: "File 'dsos2.png' uploaded successfully. Another file of the same name in the same location was overwritten.",
Name: 'dsos2.png',
ExternalKey: 'ad2c32c8-ae5a-41d9-885c-5f31f0d3a748'
}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
srcFilePath |
string | Path of the file to be uploaded |
||
destDirPath |
string |
<optional> |
''
|
Upload destination by path (i.e., the path of the destination folder). If |
newFileNameNoExt |
string |
<optional> |
''
|
New name for the file to be uploaded (almost like a "Save As" option). It should not contain the file extension--this will be deduced from the first argument, |
Returns:
Object with information about the upload attempt (i.e., status
, statusText
, message
, Name
, and ExternalKey
, where Name
represents the name of the uploaded file and ExternalKey
the file's assigned ID). If the status
value is 200
, then a file of the same name in the same location was overwritten. If the status
value is 200
(with statusText
of 'OK'
), then a file of the same name in the same location was overwritten. If the status value is 201
(with statusText
of 'Created'
), then the file was uploaded without any other file being overwritten.
- Type
- Promise.<{status: (200|201), statusText: ('OK'|'Created'), message: string, Name: string, ExternalKey: string}>