Interface
import type { DbDataSource } from "../db/interface";
interface CloudDatabase extends Omit<DbDataSource, "parallel" | "withCommand" | "usePool"> {
source: "cloud";
service: string;
id?: string;
params?: unknown;
}
interface CloudStorage {
service: string;
credential: unknown;
bucket?: string;
admin?: CloudStorageAdmin;
upload?: CloudStorageUpload;
download?: CloudStorageDownload;
}
interface CloudStorageAdmin extends CloudStorageACL {
emptyBucket?: boolean;
configBucket?: {
create?: unknown;
policy?: unknown;
website?: {
indexPage?: string;
errorPage?: string;
indexPath?: string;
errorPath?: string;
};
retentionPolicy?: unknown;
};
recursive?: boolean;
preservePath?: boolean;
}
interface CloudStorageAction {
pathname?: string;
filename?: string;
minStreamSize?: number | string;
chunkSize?: number | string;
chunkLimit?: number;
flags?: number;
active?: boolean;
overwrite?: boolean;
admin?: CloudStorageAdmin;
}
interface CloudStorageUpload extends CloudStorageACL, CloudStorageAction {
buffer?: Buffer | null;
contentType?: string;
metadata?: Record<string, string>;
tags?: Record<string, string> | false;
options?: unknown;
fileGroup?: [Buffer | string, string, string?][];
localStorage?: boolean;
endpoint?: string;
all?: boolean;
}
interface CloudStorageACL {
publicRead?: boolean | 0;
acl?: string;
}
interface CloudStorageDownload extends CloudStorageAction {
keyname?: string;
versionId?: string;
options?: unknown;
deleteObject?: unknown;
waitStatus?: boolean;
}
Added in version 0.9.0:
CloudStorageAction property chunkSize | chunkLimit for parallel multipart operations.
CloudStorageDownload property options to customize the provider download client.
CloudStorageDownload property keyname for file to be downloaded and subsequently renamed to filename.
Admin
Auth
Internal use of these libraries that do not require credentials validation during service client API initialization can disable this behavior through settings. There are also cases where an unsupported authorization scheme is necessary which has not been implemented.
Caution
These are global settings and affect every connection per service.
{
"settings": {
"aws": {
"auth": {
"storage": true, // Default behavior
"database": false // Explicit to disable
}
}
}
}
Added in version 0.9.0:
Credentials validation bypass settings in squared.cloud.json (1.4.0) were created.
Storage
Service |
CLOUD_UPLOAD_STREAM |
CLOUD_UPLOAD_CHUNK |
CLOUD_DOWNLOAD_CHUNK |
---|---|---|---|
aws |
X |
X |
|
aws-v3 |
X |
X |
|
azure |
X |
X |
X |
gcp |
X |
X |
X |
ibm |
X |
X |
|
minio |
X |
||
oci |
X |
X |
Caution
Setting process.env.EMC_CLOUD_UPLOAD_BUFFER = "true"
will enable the legacy behavior for Document based uploads.
Stream
Streaming was enabled by default due to its lower memory usage requirements. It is slower for small file transfers which is typical for a static web page.
Tip
Setting upload.minStreamSize = -1
will disable streaming for the current request.
const aws = require("@pi-r/aws");
aws.CLOUD_UPLOAD_STREAM = false;
Warning
Reading a buffer from disk has 2gb file size limit.
Chunk
Parallel transfers were enabled by default to accommodate large files. The old behavior is used when chunkSize is empty and will open one request per file.
const azure = require("@pi-r/azure");
azure.CLOUD_UPLOAD_CHUNK = false;
azure.CLOUD_DOWNLOAD_CHUNK = false;
Note
Chunking is only active when the upload file size is greater than chunkSize.