Skip to content

Instantly share code, notes, and snippets.

@VonStruddle
Last active October 19, 2022 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VonStruddle/6d440edaf776857c4458f6c0752ca1fa to your computer and use it in GitHub Desktop.
Save VonStruddle/6d440edaf776857c4458f6c0752ca1fa to your computer and use it in GitHub Desktop.
Airtable / Xano CDN automation
const xanoBaseUrl = 'https://xc0b-vcze-d4we.n7.xano.io' // Edit this variable to match your Xano instance subdomain
let table = base.getTable('property')
let config = input.config()
let recordId = config.updatedRecordId
let record = await table.selectRecordAsync(recordId, {fields: table.fields})
let images = record.getCellValue('images') // Update this value to match your image/file attachment column
let imagesUrlCdn = []
for (let image of images) {
let imageUrl = image.url
let result = await fetch(xanoBaseUrl + '/api:SJOHbPGi/upload/image', { // Update this path to match your Xano upload file endpoint
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({'content': imageUrl})
})
let response = await result.json()
let imageUrlCdn = xanoBaseUrl + response.path
imagesUrlCdn.push(imageUrlCdn)
}
await table.updateRecordAsync(record, {
'images_urls': imagesUrlCdn.join() // Update the key to match your newsly created URL column
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment