|
1515 | 1515 | <input type="hidden" id="node-input-mimeTypetype"> |
1516 | 1516 | <input style="width:70%" type="text" id="node-input-mimeType" placeholder="Mimetype of file"> |
1517 | 1517 | </div> |
| 1518 | + <div class="form-row"> |
| 1519 | + <label><i class="fa fa-tag"></i> File Content</label> |
| 1520 | + <input type="hidden" id="node-input-contenttype"> |
| 1521 | + <input style="width:70%" type="text" id="node-input-content" placeholder="Base64 encoded file content"> |
| 1522 | + </div> |
| 1523 | + <div class="form-row"> |
| 1524 | + <label><i class="fa fa-list"></i> DB Entity</label> |
| 1525 | + <input type="hidden" id="node-input-entitytype"> |
| 1526 | + <input style="width:70%" type="text" id="node-input-entity"> |
| 1527 | + </div> |
1518 | 1528 | <div class="form-row"> |
1519 | 1529 | <label><i class="fa fa-tag"></i> Name</label> |
1520 | 1530 | <input type="text" id="node-input-name" placeholder="Node name"> |
|
1523 | 1533 | <script type="text/x-red" data-help-name="api upload file"> |
1524 | 1534 | Upload a file to API/GridFS<br> |
1525 | 1535 | msg.payload should be a base64 encode string of the file.<br> |
1526 | | - you can set filename using msg.filename<br> |
1527 | | - you can set mimeType using msg.mimeType<br> |
1528 | 1536 | to save data with the file set msg.metadata to and javascript object<br> |
1529 | 1537 | </script> |
1530 | 1538 | <script type="text/javascript"> |
|
1534 | 1542 | paletteLabel: 'upload', |
1535 | 1543 | icon: "font-awesome/fa-upload", |
1536 | 1544 | defaults: { |
1537 | | - filename: { value: "", validate: validate("filenametype"), required: true }, |
| 1545 | + filename: { value: "filename", validate: validate("filename"), required: true }, |
1538 | 1546 | filenametype: { value: "" }, |
1539 | | - mimeType: { value: "", validate: validate("mimeTypetype"), required: true }, |
| 1547 | + content: { value: "payload", validate: validate("content"), required: true }, |
| 1548 | + contenttype: { value: "" }, |
| 1549 | + mimeType: { value: "", validate: RED.validators.typedInput("mimeTypetype") }, |
1540 | 1550 | mimeTypetype: { value: "" }, |
| 1551 | + entity: { value: "result", validate: RED.validators.typedInput("mimeTypetype") }, |
| 1552 | + entitytype: { value: "" }, |
1541 | 1553 | name: { value: "" } |
1542 | 1554 | }, |
1543 | 1555 | inputs: 1, |
|
1551 | 1563 | oneditprepare: function () { |
1552 | 1564 | if (this.filenametype === 'val') $("#node-input-filenametype").val('str'); |
1553 | 1565 | $("#node-input-filename").typedInput({ |
1554 | | - default: 'str', |
| 1566 | + default: 'msg', |
1555 | 1567 | typeField: $("#node-input-filenametype"), |
1556 | 1568 | types: ['msg', 'str', 'flow', 'global', 'json'] |
1557 | 1569 | }); |
| 1570 | + if (this.contenttype === 'val') $("#node-input-contenttype").val('str'); |
| 1571 | + $("#node-input-content").typedInput({ |
| 1572 | + default: 'msg', |
| 1573 | + typeField: $("#node-input-contenttype"), |
| 1574 | + types: ['msg'] |
| 1575 | + }); |
1558 | 1576 | if (this.mimeTypetype === 'val') $("#node-input-mimeTypetype").val('str'); |
1559 | 1577 | $("#node-input-mimeType").typedInput({ |
1560 | 1578 | default: 'str', |
1561 | 1579 | typeField: $("#node-input-mimeTypetype"), |
1562 | 1580 | types: ['msg', 'str', 'flow', 'global', 'json'] |
1563 | 1581 | }); |
| 1582 | + if (this.entitytype === 'val') $("#node-input-entitytype").val('str'); |
| 1583 | + $("#node-input-entity").typedInput({ |
| 1584 | + default: 'msg', |
| 1585 | + typeField: $("#node-input-entitytype"), |
| 1586 | + types: ['msg'] |
| 1587 | + }); |
1564 | 1588 | }, |
1565 | 1589 | }); |
1566 | 1590 | </script> |
|
0 commit comments