# \[PR\] add typed input for filename prop on native file(in) node

**URL:** <https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253>\
**Category:** Feature Requests\
**Created:** [5 April 2020 08:15 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253 "2020-04-05T08:15:11Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bug00](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@bug00](https://discourse.nodered.org/u/bug00)\
**Post date:** [5 April 2020 08:15 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/1 "2020-04-05T08:15:11Z")

</div>

Hi,

i have fork node and extend file / file in node on filename properties for add choice of input type (msg, str, jsonata, ...)

Default it's str type with "" value, then old confidg node won't be impacted by this small change.

BTW it's my first fork and PR, maybe i don't doing thing right 😊

Thank for time past in reply 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [5 April 2020 08:28 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/2 "2020-04-05T08:28:31Z")

</div>

The normal method when having an idea for an enhancement to core nodes is to talk about it first and get agreement that its a good idea before issuing a PR 🙂

---

<div class="post-metadata">

**Author:** ![bug00](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@bug00](https://discourse.nodered.org/u/bug00)\
**Post date:** [5 April 2020 08:36 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/3 "2020-04-05T08:36:13Z")

</div>

Yep, i havent create a PR yet, before i open this topic 🙂

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2020 09:23 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/4 "2020-04-05T09:23:00Z")

</div>

If I understand - you are replacing the textbox for `filename` with a typedInput?

What options are you intending to include?  
string, msg, flow, global, jsonata all certainly make sense.

+1 from me as its a pet peeve of mine - having to add change nodes before a node simply to move a property into the `payload` or `filename` field.

So long as it is 100% compatible, I cant see why this wouldn't be accepted. (though I might be under-thinking this)

Fingers crossed you get the OK. 🤞

---

<div class="post-metadata">

**Author:** ![bug00](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@bug00](https://discourse.nodered.org/u/bug00)\
**Post date:** [5 April 2020 09:55 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/5 "2020-04-05T09:55:37Z")

</div>

> [@Steve-Mcl](#):
>
> aving to add change nodes before a node simply to move a property into the `payload` or `filename` field

You understand ! It's crazy to have 2 nodes, one for fill filename and other to perform file operation !

I have include all type (even env var)

The point it's 100% compatible, on my test everything it s ok but... we need more test...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 April 2020 11:53 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/6 "2020-04-05T11:53:31Z")

</div>

it's not crazy - it's one of the main tenets of Node-RED - nodes should do their thing and do it well - moving properties around is the function of the change node - reading files is the function of the file node.

There is certainly no need to include all types - don't need boolean, number, buffer, etc.

Does this also apply to the file out node ? Note: there is a performance penalty if you use anything other than a fixed value as it has to close the file every write - just in case the next filename value is different.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2020 12:21 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/7 "2020-04-05T12:21:00Z")

</div>

Haha no it's not crazy but it is (to me anyhoo) a bit annoying when we have the fabulous typedinput at our disposal.

_(IMHO, I wish all nodes which work on input msg parameters made use of typedinput - it's a tremendous feature of node-red)_

In the interest of diplomacy, if the OP met the following conditions (plus any you stipulate), would you consider the PR Dave?

- typedinput supports string, flow, global, jasonata, env (that's about all I think it needs)
- by default, string type is set
- both file in and file out node are done the same
- 100% compatibly with existing flows

Ps. I fully expect I might be missing something so please advise.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 April 2020 12:29 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/8 "2020-04-05T12:29:56Z")

</div>

Note I didn't say no ... just need to think about it a bit first (as we are doing)...

so yes - default must be string - and if that is blank it must still look for msg.filename (as now).  
Will also need tests added to test/nodes/core/storage/10-file\_spec.js to exercise new functionallity.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 April 2020 12:36 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/9 "2020-04-05T12:36:24Z")

</div>

> [@dceejay](#):
>
> and if that is blank it must still look for msg.filename (as now).

I missed that one dammit. Good to see you are as annoyingly thorough as always. 😉

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [5 April 2020 13:08 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/10 "2020-04-05T13:08:03Z")

</div>

well there is a test for that already so it should have found it...

---

<div class="post-metadata">

**Author:** ![bug00](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@bug00](https://discourse.nodered.org/u/bug00)\
**Post date:** [6 April 2020 07:03 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/11 "2020-04-06T07:03:43Z")

</div>

Sorry for the wrord 'crazy"... I m a frog legs eater, and i m not confortable in English...

Then if you forgive me, i understand very well the atomic philosophy of a node, but i think typed input are for this probleme (easily retrieve object attach on msg)

Yep, all type are not necessary and you listed those i used. Default type are str, for compatibilty and if field is blank we look on msg.filename. Change made on both node.

In fact there 2 lines change in .js, would you like that i copy here the lines ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 April 2020 07:12 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/12 "2020-04-06T07:12:17Z")

</div>

No problem, I'd like a pull request with tests please, so we can check it and hopefully merge it.

---

<div class="post-metadata">

**Author:** ![bug00](https://avatars.discourse-cdn.com/v4/letter/b/9de0a6/32.png) [@bug00](https://discourse.nodered.org/u/bug00)\
**Post date:** [6 April 2020 12:32 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/13 "2020-04-06T12:32:37Z")

</div>

Sorry i haven't yet good practice.

What you mean by test ? screenshot ? or test like unit test ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 April 2020 16:14 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/14 "2020-04-06T16:14:06Z")

</div>

unit tests - as in add tests to [https://github.com/node-red/node-red/blob/master/test/nodes/core/storage/10-file\_spec.js](https://github.com/node-red/node-red/blob/master/test/nodes/core/storage/10-file_spec.js)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [5 June 2020 16:23 UTC](https://discourse.nodered.org/t/pr-add-typed-input-for-filename-prop-on-native-file-in-node/24253/15 "2020-06-05T16:23:33Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
