diff --git a/packages/cli/BREAKING-CHANGES.md b/packages/cli/BREAKING-CHANGES.md
index 503917fe6a..e1a52ff9c3 100644
--- a/packages/cli/BREAKING-CHANGES.md
+++ b/packages/cli/BREAKING-CHANGES.md
@@ -2,6 +2,48 @@
This list shows all the versions which include breaking changes and how to upgrade
+## 0.19.0
+
+### What changed?
+
+The node "Read File From Url" got removed as its functionality got added to
+"HTTP Request" node where it belongs.
+
+### When is action necessary?
+
+If the "Read File From Url" gets used in any workflow.
+
+### How to upgrade:
+
+After upgrading open all workflows which contain a "Read File From Url" node.
+They will have a "?" as icon as they are not known anymore. Create a new
+"HTTP Request" node to replace the old one and add the same URL as the previous
+node had (in case you do not know it anymore you can select the old node, copy
+it and paste it in a text-editor, it will display all the data the node
+contained). Then set the "Response Format" to "File". Everything will then
+function again like before.
+
+
+----------------------------
+
+
+### What changed?
+
+When "HTTP Request" property "Response Format" was set to "String" it did save
+the data by default in the property "response". In the new version that can now
+be configured. The default value got also changed from "response" to "data" to
+match other nodes with similar functionality.
+
+### When is action necessary?
+
+When "HTTP Request" nodes get used which have "Response Format" set to "String".
+
+### How to upgrade:
+
+After upgrading open all workflows which contain the concerning Nodes and set
+"Binary Property" to "response".
+
+
## 0.18.0
### What changed?
diff --git a/packages/nodes-base/nodes/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest.node.ts
index 1839b7cfb6..adfc848340 100644
--- a/packages/nodes-base/nodes/HttpRequest.node.ts
+++ b/packages/nodes-base/nodes/HttpRequest.node.ts
@@ -27,7 +27,7 @@ export class HttpRequest implements INodeType {
version: 1,
description: 'Makes a HTTP request and returns the received data',
defaults: {
- name: 'Http Request',
+ name: 'HTTP Request',
color: '#2200DD',
},
inputs: ['main'],
@@ -143,6 +143,10 @@ export class HttpRequest implements INodeType {
name: 'responseFormat',
type: 'options',
options: [
+ {
+ name: 'File',
+ value: 'file'
+ },
{
name: 'JSON',
value: 'json'
@@ -151,14 +155,43 @@ export class HttpRequest implements INodeType {
name: 'String',
value: 'string'
},
- // {
- // name: 'XML (not implemented)',
- // value: 'xml'
- // },
],
default: 'json',
description: 'The format in which the data gets returned from the URL.',
},
+
+ {
+ displayName: 'Property Name',
+ name: 'dataPropertyName',
+ type: 'string',
+ default: 'data',
+ required: true,
+ displayOptions: {
+ show: {
+ responseFormat: [
+ 'string',
+ ],
+ },
+ },
+ description: 'Name of the property to which to write the response data.',
+ },
+ {
+ displayName: 'Binary Property',
+ name: 'dataPropertyName',
+ type: 'string',
+ default: 'data',
+ required: true,
+ displayOptions: {
+ show: {
+ responseFormat: [
+ 'file',
+ ],
+ },
+
+ },
+ description: 'Name of the binary property to which to
write the data of the read file.',
+ },
+
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
@@ -350,12 +383,13 @@ export class HttpRequest implements INodeType {
// TODO: Should have a setting which makes clear that this parameter can not change for each item
const requestMethod = this.getNodeParameter('requestMethod', 0) as string;
const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean;
+ const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
const httpBasicAuth = this.getCredentials('httpBasicAuth');
const httpDigestAuth = this.getCredentials('httpDigestAuth');
const httpHeaderAuth = this.getCredentials('httpHeaderAuth');
- let url: string, responseFormat: string;
+ let url: string;
let requestOptions: OptionsWithUri;
let setUiParameter: IDataObject;
@@ -383,7 +417,6 @@ export class HttpRequest implements INodeType {
const returnItems: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
url = this.getNodeParameter('url', itemIndex) as string;
- responseFormat = this.getNodeParameter('responseFormat', itemIndex) as string;
requestOptions = {
headers: {},
@@ -432,7 +465,6 @@ export class HttpRequest implements INodeType {
}
}
}
- requestOptions.json = true;
// Add credentials if any are set
if (httpBasicAuth !== undefined) {
@@ -452,18 +484,54 @@ export class HttpRequest implements INodeType {
};
}
+ if (responseFormat === 'file') {
+ requestOptions.encoding = null;
+ } else {
+ requestOptions.json = true;
+ }
+
// Now that the options are all set make the actual http request
const response = await this.helpers.request(requestOptions);
- if (responseFormat === 'json') {
- returnItems.push({ json: response });
- // } else if (responseFormat === 'xml') {
- // // TODO: Not implemented yet
+ if (responseFormat === 'file') {
+ const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
+
+ const newItem: INodeExecutionData = {
+ json: items[itemIndex].json,
+ binary: {},
+ };
+
+ if (items[itemIndex].binary !== undefined) {
+ // Create a shallow copy of the binary data so that the old
+ // data references which do not get changed still stay behind
+ // but the incoming data does not get changed.
+ Object.assign(newItem.binary, items[itemIndex].binary);
+ }
+
+ items[itemIndex] = newItem;
+
+ const fileName = (url).split('/').pop();
+
+ items[itemIndex].binary![dataPropertyName] = await this.helpers.prepareBinaryData(response, fileName);
+ } else if (responseFormat === 'json') {
+ const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string;
+
+ returnItems.push({
+ json: {
+ [dataPropertyName]: response,
+ }
+ });
} else {
returnItems.push({ json: { response } });
}
}
- return this.prepareOutputData(returnItems);
+ if (responseFormat === 'file') {
+ // For file downloads the files get attached to the existing items
+ return this.prepareOutputData(items);
+ } else {
+ // For all other ones does the output items get replaced
+ return [this.helpers.returnJsonArray(returnItems)];
+ }
}
}
diff --git a/packages/nodes-base/nodes/ReadFileFromUrl.node.ts b/packages/nodes-base/nodes/ReadFileFromUrl.node.ts
deleted file mode 100644
index 4fb9ef33df..0000000000
--- a/packages/nodes-base/nodes/ReadFileFromUrl.node.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { IExecuteSingleFunctions } from 'n8n-core';
-import {
- INodeTypeDescription,
- INodeExecutionData,
- INodeType,
-} from 'n8n-workflow';
-import { UriOptions } from 'request';
-
-
-export class ReadFileFromUrl implements INodeType {
- description: INodeTypeDescription = {
- displayName: 'Read File From Url',
- name: 'readFileFromUrl',
- icon: 'fa:file-download',
- group: ['input'],
- version: 1,
- description: 'Reads a file from an URL',
- defaults: {
- name: 'Read File URL',
- color: '#119955',
- },
- inputs: ['main'],
- outputs: ['main'],
- properties: [
- {
- displayName: 'URL',
- name: 'url',
- type: 'string',
- default: '',
- required: true,
- placeholder: 'http://example.com/index.html',
- description: 'URL of the file to read.',
- },
- {
- displayName: 'Property Name',
- name: 'dataPropertyName',
- type: 'string',
- default: 'data',
- description: 'Name of the binary property to which to
write the data of the URL.',
- },
- {
- displayName: 'Ignore SSL Issues',
- name: 'allowUnauthorizedCerts',
- type: 'boolean',
- default: false,
- description: 'Still download the file even if SSL certificate validation is not possible.',
- },
- ]
- };
-
-
- async executeSingle(this: IExecuteSingleFunctions): Promise {
- const url = this.getNodeParameter('url') as string;
- const dataPropertyName = this.getNodeParameter('dataPropertyName') as string;
-
- const options: UriOptions = {
- uri: url,
- // @ts-ignore
- encoding: null,
- rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', false) as boolean,
- };
-
- // TODO: Should have a catch here
- const data = await this.helpers.request(options);
-
- // Get the filename and also add it to the binary data
- const fileName = (url).split('/').pop();
-
- // Get the current item and add the binary data
- const item = this.getInputData();
-
- const newItem: INodeExecutionData = {
- json: item.json,
- binary: {},
- };
-
- if (item.binary !== undefined) {
- // Create a shallow copy of the binary data so that the old
- // data references which do not get changed still stay behind
- // but the incoming data does not get changed.
- Object.assign(newItem.binary, item.binary);
- }
-
- newItem.binary![dataPropertyName as string] = await this.helpers.prepareBinaryData(data, fileName);
-
- return newItem;
- }
-}
diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json
index 3b2e8e9466..4bcb1ecd4e 100644
--- a/packages/nodes-base/package.json
+++ b/packages/nodes-base/package.json
@@ -83,7 +83,6 @@
"dist/nodes/ReadBinaryFile.node.js",
"dist/nodes/ReadBinaryFiles.node.js",
"dist/nodes/Redis/Redis.node.js",
- "dist/nodes/ReadFileFromUrl.node.js",
"dist/nodes/ReadPdf.node.js",
"dist/nodes/RenameKeys.node.js",
"dist/nodes/RssFeedRead.node.js",