Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

2.4 KB
Raw Blame
import { Component } from './Component.class';
declare var Metro;

export class FileStore extends Component {
  protected async init() {
    this.settings = {
      name: {
        type: 'input',
        label: 'File Name',
        help: 'Name the download and include an extension like .json or .png for easy use. <a href="https://smythos.com/docs/agent-studio/components/advanced/filestore/?utm_source=studio&utm_medium=tooltip&utm_campaign=filestore&utm_content=file-name#step-1-define-inputs" target="_blank" class="text-blue-600 hover:text-blue-800">See naming tips</a>',
        tooltipClasses: 'w-64',
        validate: `maxlength=50 custom=isValidS3FileName`,
        validateMessage: `Only alphanumeric characters, '-', '_' and '.' are allowed.`,
        value: '',
        attributes: { 'data-template-vars': 'true' },
      },
      ttl: {
        type: 'select',
        label: 'TTL',
        value: '86400', // Default to 1 day
        help: 'Set how long the public link stays valid before it expires. <a href="https://smythos.com/docs/agent-studio/components/advanced/filestore/?utm_source=studio&utm_medium=tooltip&utm_campaign=filestore&utm_content=ttl#step-1-define-inputs" target="_blank" class="text-blue-600 hover:text-blue-800">See TTL options</a>',
        tooltipClasses: 'w-28',
        arrowClasses: '-ml-11',
        options: [
          {
            value: '86400',
            text: '1 day',
          },
          {
            value: '259200',
            text: '3 days',
          },
          {
            value: '604800',
            text: '1 week',
          },
          {
            value: '1209600',
            text: '2 weeks',
          },
          {
            value: '2592000',
            text: '1 month',
          },
        ],
      },
    };

    const dataEntries = ['name', 'ttl'];
    for (let item of dataEntries) {
      if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
    }

    this.properties.defaultOutputs = ['Url'];
    this.properties.defaultInputs = ['Data'];

    this.drawSettings.displayName = 'File Store';
    this.drawSettings.iconCSSClass = 'svg-icon ' + this.constructor.name;

    this.drawSettings.componentDescription = 'Store a file or data permanently';
    this.drawSettings.shortDescription = 'Store a file or data permanently';
    this.drawSettings.color = '#65a698';

    this._ready = true;
  }
}