Help

Attachments on createRecordAsync

Topic Labels: Custom Extensions
394 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Pedro_Botsaris
4 - Data Explorer
4 - Data Explorer

Hi there,

I am creating a simple extension that creates a record with an attachment. I am using createRecordAsync  from the blocks API for the record creation and the the native URL interface from the Web API to create an URL from the file loaded in by user via an `<input type="file"/>`.

URL objects

 

const handleFileChange = (e) => {
(...)
const newFiles = Array.from(e.target.files)
const fileData = newFiles.map((file) => ({
filename: file.name,
size: file.size,
type: file.type,
status: FILE_STATUS.LOADED,
url: URL.createObjectURL(file),
}))
setFiles(fileData)
}

 

then

 

(...)
table.createRecordAsync([{attachment: {filename: file.filename, url: file.url}}])

 

A record is created successfully and I get no error or warnings, however, the file is never attached to the record. 

I wanted to avoid having to go through the Airtable API.  Is it possible to create an attachment directly from an extension?  

 

Thanks,

Pedro

0 Replies 0