Comparing version 3.24.0 to 3.25.0
@@ -71,3 +71,3 @@ "use strict"; | ||
} | ||
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.24.0'); | ||
exports.HEADER_USER_AGENT = (0, default_user_agent_1.default)('node-urllib', '3.25.0'); | ||
function getFileName(stream) { | ||
@@ -360,3 +360,4 @@ const filePath = stream.path; | ||
for (const field in args.files) { | ||
uploadFiles.push([field, args.files[field]]); | ||
// set custom fileName | ||
uploadFiles.push([field, args.files[field], field]); | ||
} | ||
@@ -370,3 +371,3 @@ } | ||
} | ||
for (const [index, [field, file]] of uploadFiles.entries()) { | ||
for (const [index, [field, file, customFileName]] of uploadFiles.entries()) { | ||
if (typeof file === 'string') { | ||
@@ -381,6 +382,6 @@ // FIXME: support non-ascii filename | ||
else if (Buffer.isBuffer(file)) { | ||
formData.append(field, new node_buffer_1.Blob([file]), `bufferfile${index}`); | ||
formData.append(field, new node_buffer_1.Blob([file]), customFileName || `bufferfile${index}`); | ||
} | ||
else if (file instanceof node_stream_1.Readable || (0, utils_js_1.isReadable)(file)) { | ||
const fileName = getFileName(file) || `streamfile${index}`; | ||
const fileName = getFileName(file) || customFileName || `streamfile${index}`; | ||
formData.append(field, new BlobFromStream(file, mime_types_1.default.lookup(fileName) || ''), fileName); | ||
@@ -387,0 +388,0 @@ isStreamingRequest = true; |
@@ -65,3 +65,3 @@ import diagnosticsChannel from 'node:diagnostics_channel'; | ||
} | ||
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.24.0'); | ||
export const HEADER_USER_AGENT = createUserAgent('node-urllib', '3.25.0'); | ||
function getFileName(stream) { | ||
@@ -354,3 +354,4 @@ const filePath = stream.path; | ||
for (const field in args.files) { | ||
uploadFiles.push([field, args.files[field]]); | ||
// set custom fileName | ||
uploadFiles.push([field, args.files[field], field]); | ||
} | ||
@@ -364,3 +365,3 @@ } | ||
} | ||
for (const [index, [field, file]] of uploadFiles.entries()) { | ||
for (const [index, [field, file, customFileName]] of uploadFiles.entries()) { | ||
if (typeof file === 'string') { | ||
@@ -375,6 +376,6 @@ // FIXME: support non-ascii filename | ||
else if (Buffer.isBuffer(file)) { | ||
formData.append(field, new Blob([file]), `bufferfile${index}`); | ||
formData.append(field, new Blob([file]), customFileName || `bufferfile${index}`); | ||
} | ||
else if (file instanceof Readable || isReadable(file)) { | ||
const fileName = getFileName(file) || `streamfile${index}`; | ||
const fileName = getFileName(file) || customFileName || `streamfile${index}`; | ||
formData.append(field, new BlobFromStream(file, mime.lookup(fileName) || ''), fileName); | ||
@@ -381,0 +382,0 @@ isStreamingRequest = true; |
{ | ||
"name": "urllib", | ||
"version": "3.24.0", | ||
"version": "3.25.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "tag": "latest" |
@@ -443,3 +443,3 @@ import diagnosticsChannel from 'node:diagnostics_channel'; | ||
const formData = new FormData(); | ||
const uploadFiles: [string, string | Readable | Buffer][] = []; | ||
const uploadFiles: [string, string | Readable | Buffer, string?][] = []; | ||
if (Array.isArray(args.files)) { | ||
@@ -456,3 +456,4 @@ for (const [ index, file ] of args.files.entries()) { | ||
for (const field in args.files) { | ||
uploadFiles.push([ field, args.files[field] ]); | ||
// set custom fileName | ||
uploadFiles.push([ field, args.files[field], field ]); | ||
} | ||
@@ -466,3 +467,3 @@ } | ||
} | ||
for (const [ index, [ field, file ]] of uploadFiles.entries()) { | ||
for (const [ index, [ field, file, customFileName ]] of uploadFiles.entries()) { | ||
if (typeof file === 'string') { | ||
@@ -476,5 +477,5 @@ // FIXME: support non-ascii filename | ||
} else if (Buffer.isBuffer(file)) { | ||
formData.append(field, new Blob([ file ]), `bufferfile${index}`); | ||
formData.append(field, new Blob([ file ]), customFileName || `bufferfile${index}`); | ||
} else if (file instanceof Readable || isReadable(file as any)) { | ||
const fileName = getFileName(file) || `streamfile${index}`; | ||
const fileName = getFileName(file) || customFileName || `streamfile${index}`; | ||
formData.append(field, new BlobFromStream(file, mime.lookup(fileName) || ''), fileName); | ||
@@ -481,0 +482,0 @@ isStreamingRequest = true; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220990
4744