What is @uppy/utils?
@uppy/utils is a utility library that provides a set of helper functions for working with files, URLs, and other common tasks in JavaScript. It is part of the Uppy file uploader ecosystem and is designed to simplify various operations related to file handling and manipulation.
What are @uppy/utils's main functionalities?
getFileNameAndExtension
This function extracts the file name and extension from a given file path or URL.
const { getFileNameAndExtension } = require('@uppy/utils');
const { name, extension } = getFileNameAndExtension('example.txt');
console.log(name); // 'example'
console.log(extension); // 'txt'
getSafeFileName
This function sanitizes a file name by replacing unsafe characters with safe ones.
const { getSafeFileName } = require('@uppy/utils');
const safeName = getSafeFileName('example file.txt');
console.log(safeName); // 'example-file.txt'
generateFileID
This function generates a unique ID for a file based on its properties such as name, type, and size.
const { generateFileID } = require('@uppy/utils');
const fileID = generateFileID({ name: 'example.txt', type: 'text/plain', size: 1024 });
console.log(fileID); // A unique file ID based on the file's properties
isPreviewSupported
This function checks if a given MIME type is supported for preview.
const { isPreviewSupported } = require('@uppy/utils');
const supported = isPreviewSupported('image/jpeg');
console.log(supported); // true
Other packages similar to @uppy/utils
file-type
The 'file-type' package is used to detect the file type of a Buffer/Uint8Array/ArrayBuffer. It is similar to @uppy/utils in that it helps with file handling, but it focuses specifically on detecting file types rather than providing a broader set of utilities.
mime
The 'mime' package is used to look up the MIME type of a file based on its extension. It is similar to @uppy/utils in that it deals with file types and extensions, but it does not provide the same range of utilities for file manipulation.
sanitize-filename
The 'sanitize-filename' package is used to sanitize file names by removing or replacing unsafe characters. It is similar to the getSafeFileName function in @uppy/utils, but it is focused solely on sanitizing file names.
@uppy/utils
Shared utility functions for Uppy Core and the "official" plugins maintained by the Uppy team.
Uppy is being developed by the folks at Transloadit, a versatile file encoding service.
Installation
Unless you are creating a custom plugin, you should not need to install this manually.
$ npm install @uppy/utils --save
License
The MIT License.
2.2.1
Released: 2021-10-14
| Package | Version | Package | Version |
|-|-|-|-|
| @uppy/angular | 0.2.5 | @uppy/provider-views | 2.0.4 |
| @uppy/aws-s3-multipart | 2.1.1 | @uppy/react-native | 0.2.4 |
| @uppy/aws-s3 | 2.0.5 | @uppy/react | 2.1.1 |
| @uppy/box | 1.0.4 | @uppy/redux-dev-tools | 2.0.3 |
| @uppy/companion-client | 2.0.3 | @uppy/robodog | 2.1.1 |
| @uppy/companion | 3.1.1 | @uppy/screen-capture | 2.0.4 |
| @uppy/core | 2.1.1 | @uppy/status-bar | 2.1.1 |
| @uppy/dashboard | 2.1.1 | @uppy/store-default | 2.0.2 |
| @uppy/drag-drop | 2.0.4 | @uppy/store-redux | 2.0.2 |
| @uppy/drop-target | 1.1.1 | @uppy/svelte | 1.0.5 |
| @uppy/dropbox | 2.0.4 | @uppy/thumbnail-generator | 2.0.5 |
| @uppy/facebook | 2.0.4 | @uppy/transloadit | 2.0.4 |
| @uppy/file-input | 2.0.4 | @uppy/tus | 2.1.1 |
| @uppy/form | 2.0.4 | @uppy/unsplash | 2.0.1 |
| @uppy/golden-retriever | 2.0.5 | @uppy/url | 2.0.4 |
| @uppy/google-drive | 2.0.4 | @uppy/utils | 4.0.3 |
| @uppy/image-editor | 1.0.4 | @uppy/vue | 0.4.3 |
| @uppy/informer | 2.0.4 | @uppy/webcam | 2.0.4 |
| @uppy/instagram | 2.0.4 | @uppy/xhr-upload | 2.0.5 |
| @uppy/locales | 2.0.3 | @uppy/zoom | 1.0.4 |
| @uppy/onedrive | 2.0.4 | uppy | 2.2.1 |
| @uppy/progress-bar | 2.0.4 | - | - |
- @uppy/locale: Update ar_SA.js (issa.ahmd@gmail.com / #3192)
- @uppy/status-bar: fix
calculateProcessingProgress
is not a function (@aduh95 / #3261) - @uppy/status-bar: Progress object is nested (@arturi / #3262)
- build: Add retext to markdown linter (@aduh95 / #3024)
- build: Bump tar from 6.1.2 to 6.1.9 (dependabot / #3152)
- website: Revert "Remove broken link in
plugin_list.ejs
(@aduh95 / #3166)