0.2.0 • Published 2 years ago
s3-key v0.2.0
S3-key
An AWS S3 utility library.
Usage
Install
yarn add s3-key
Polyfill
- The project requires
String.replaceAll. You need to polyfill it if your JavaScript engine doesn't support it.
import 'core-js/features/string/replace-all'Exported functions
- Sanitize an arbitrary string to a valid s3 key (such as converting space to plus).
export declare const sanitizeS3Key: (key: string, { charLimit = 512, replacementCharacter = '+', }?: {}) => string;- Extended version of
encodeURIwhich encodes s3 key to URL string.
export declare const encodeS3Key: (key: string) => string;- Extended version of
decodeURIwhich decode the value encoded byencodeS3Key.
export declare const decodeS3Key: (encodedKey: string) => string;Advanced functions
- AWS states that some characters should be avoided. But in fact, they still admit them.
disallowAvoidedCharactersis an internal flag controlled bysetDisallowAvoidedCharacters, isfalseby default. This flag should be disabled when we want a (better) one-to-one relationship between the input key andencodedKeysuch as in the image handler service.
export declare const setDisallowAvoidedCharacters: (val: boolean) => void;