ToolJet/docs/versioned_docs/version-2.33.0/how-to/upload-files-gcs.md
Aman Regu 72fa067550
[docs]: Update formatting for How To section (#9169)
* Updated the formatting of how to docs for the next and current versions

* Used the title cases in the heading

* Updated the formatting of how to docs for the next and current versions

* Used the title cases in the heading

* updated the formatting of inspector, form, cell colors

* resolved conflicts

* Updated the formatting of bulk update multiple rows, conditionaly format table, delete multiple rows, serverside pagination

* Updated access user groups, import external lib in js and python, use axios

* fix: border colour, blur

* Revert changes to versions.json

* Changed the formatting of how to docs

* add changes from docs/next to v2.34.0

* update: how to docs

* fix: image name create-new-query

* fix: image name import-successful.png

* fix: image name flatten-js

* fix: image name math-js-v2

* update: shorten page titles

---------

Co-authored-by: Asjad Ahmed Khan <iitasjad2001@gmail.com>
Co-authored-by: Karan Rathod <karan.altcampus@gmail.com>
2024-04-11 11:34:27 +05:30

3 KiB

id title
upload-files-gcs Upload Files Using GCS

In this guide, we are going to create an interface to upload PDFs to Google Cloud Storage.

Before adding the new data source we will need to have a private key for our GCS bucket and make sure the key has the appropriate rights.

Setting up Google Cloud Storage Data Source

  1. Go to the data source manager on the left-sidebar and click on the + button.
  2. Add a new GCS data source from the APIs section in modal that pops up.
  3. Enter the JSON private key for service account and test the connection.
  4. Click on Save to add the data source.

ToolJet - How To - Upload files using GCS

Adding a File Picker

  1. Drag and drop the file picker widget on the canvas
  2. Configure the file picker:
  • Change the Accept file types to {{"application/pdf"}} for the picker to accept only pdf files. In the screenshot below, we have set the accepted file type property to {{"application/pdf"}} so it will allow to select only pdf files:

ToolJet - How To - Upload files using GCS

  • Change the Max file count to {{1}} as we are only going to upload 1 file at a time.
  1. Select a pdf file and hold it in the file picker.

:::info File types must be valid MIME type according to input element specification or a valid file extension.

To accept any/all file type(s), set Accept file types to an empty value. :::

ToolJet - How To - Upload files using GCS

Creating a Query

  1. Click on the + button of the query manager at the bottom panel of the editor and select the GCS data source
  2. Select Upload file operation and enter the required parameters:
  • Bucket: gs://test-1
  • File Name: {{components.file1.file[0]['name']}}
  • Content Type: {{components.file1.file[0]['type']}}
  • Upload data: {{components.file1.file[0]['base64Data']}}
  • Encoding: base64
  1. Click on Save to create the query

Running the Query

  1. Add a button that will fire the query to upload the file
  2. Edit the properties of the button and add a event handler to Run the query on On-Click event.
  3. Click on Button to fire the query, this will upload the pdf file that you selected earlier through the file picker and will upload it on the GCS.

ToolJet - How To - Upload files using GCS