Socket
Socket
Sign inDemoInstall

formdata-node

Package Overview
Dependencies
5
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.3.2 to 3.4.0

1

@type/File.d.ts
/// <reference types="node" />
import { Readable } from "stream";
import Blob from "fetch-blob";
export { Blob };
export interface FileLike {

@@ -5,0 +6,0 @@ /**

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.File = void 0;
exports.File = exports.Blob = void 0;
const fetch_blob_1 = __importDefault(require("fetch-blob"));
exports.Blob = fetch_blob_1.default;
class File extends fetch_blob_1.default {

@@ -18,2 +19,5 @@ /**

constructor(blobParts, name, options = {}) {
if (arguments.length < 2) {
throw new TypeError("Failed to construct 'File': 2 arguments required, but only 1 present.");
}
super(blobParts, options);

@@ -20,0 +24,0 @@ this.name = name;

@@ -26,2 +26,3 @@ "use strict";

const isPlainObject_1 = __importDefault(require("./util/isPlainObject"));
const getMimeFromFilename_1 = __importDefault(require("./util/getMimeFromFilename"));
const MESSAGE = "The requested file could not be read, "

@@ -80,6 +81,12 @@ + "typically due to permission problems that have occurred after a reference "

const file = new FileFromPath({ path, size, lastModified: mtimeMs });
if (!filename) {
filename = file.name;
}
if (!options.lastModified) {
options.lastModified = file.lastModified;
}
return new File_1.File([file], filename || file.name, options);
if (!options.type) {
options.type = getMimeFromFilename_1.default(filename);
}
return new File_1.File([file], filename, options);
}

@@ -86,0 +93,0 @@ function fileFromPathSync(path, filenameOrOptions, options = {}) {

3

lib/cjs/FormData.js

@@ -38,3 +38,2 @@ "use strict";

const createBoundary_1 = __importDefault(require("./util/createBoundary"));
const getMimeFromFilename_1 = __importDefault(require("./util/getMimeFromFilename"));
const isReadStream_1 = __importDefault(require("./util/isReadStream"));

@@ -93,3 +92,3 @@ const getFilename_1 = __importDefault(require("./util/getFilename"));

header += `; filename="${value.name}"${CRLF}`;
header += `Content-Type: ${value.type || getMimeFromFilename_1.default(value.name)}`;
header += `Content-Type: ${value.type || "application/octet-stream"}`;
}

@@ -96,0 +95,0 @@ return `${header}${CRLF.repeat(2)}`;

import Blob from "fetch-blob";
export { Blob };
export class File extends Blob {

@@ -11,2 +12,5 @@ /**

constructor(blobParts, name, options = {}) {
if (arguments.length < 2) {
throw new TypeError("Failed to construct 'File': 2 arguments required, but only 1 present.");
}
super(blobParts, options);

@@ -13,0 +17,0 @@ this.name = name;

@@ -20,2 +20,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {

import isPlainObject from "./util/isPlainObject.js";
import getMime from "./util/getMimeFromFilename.js";
const MESSAGE = "The requested file could not be read, "

@@ -74,6 +75,12 @@ + "typically due to permission problems that have occurred after a reference "

const file = new FileFromPath({ path, size, lastModified: mtimeMs });
if (!filename) {
filename = file.name;
}
if (!options.lastModified) {
options.lastModified = file.lastModified;
}
return new File([file], filename || file.name, options);
if (!options.type) {
options.type = getMime(filename);
}
return new File([file], filename, options);
}

@@ -80,0 +87,0 @@ export function fileFromPathSync(path, filenameOrOptions, options = {}) {

@@ -32,3 +32,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import createBoundary from "./util/createBoundary.js";
import getMime from "./util/getMimeFromFilename.js";
import isReadStream from "./util/isReadStream.js";

@@ -87,3 +86,3 @@ import getFilename from "./util/getFilename.js";

header += `; filename="${value.name}"${CRLF}`;
header += `Content-Type: ${value.type || getMime(value.name)}`;
header += `Content-Type: ${value.type || "application/octet-stream"}`;
}

@@ -90,0 +89,0 @@ return `${header}${CRLF.repeat(2)}`;

{
"name": "formdata-node",
"version": "3.3.2",
"version": "3.4.0",
"description": "FormData implementation for Node.js. Built over Readable stream and async generators.",

@@ -49,4 +49,4 @@ "repository": "octet-stream/form-data",

"@types/supertest": "2.0.11",
"@typescript-eslint/eslint-plugin": "4.23.0",
"@typescript-eslint/parser": "4.23.0",
"@typescript-eslint/eslint-plugin": "4.24.0",
"@typescript-eslint/parser": "4.24.0",
"@zoltu/typescript-transformer-append-js-extension": "1.0.1",

@@ -53,0 +53,0 @@ "ava": "3.15.0",

@@ -93,3 +93,3 @@ # FormData

```js
import {FormData, fileFromPathSync} from "formdata-node"
import {FormData, fileFromPath} from "formdata-node"

@@ -100,3 +100,3 @@ import fetch from "node-fetch"

fd.set("file", fileFromPathSync("/path/to/a/file"))
fd.set("file", await fileFromPath("/path/to/a/file"))

@@ -294,3 +294,4 @@ await fetch("https://httpbin.org/post", {method: "post", body: fd})

- [`fetch-blob`](https://github.com/bitinn/fetch-blob) a Blob implementation on node.js, originally from node-fetch.
- [`form-data-encoder`](https://github.com/octet-stream/form-data-encoder) - Encoder for multipart/form-data
- [`then-busboy`](https://github.com/octet-stream/then-busboy) a promise-based wrapper around Busboy. Process multipart/form-data content and returns it as a single object. Will be helpful to handle your data on the server-side applications.
- [`@octetstream/object-to-form-data`](https://github.com/octet-stream/object-to-form-data) converts JavaScript object to FormData.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc