I am trying to upload base64 image to transloadit but enable to do it. Getting error:
The argument 'path' must be a string or Uint8Array without null bytes. Received <Buffer
Code:
const Transloadit = require('transloadit')
const transloadit = new Transloadit({
authKey: '',
authSecret: '',
})
(async () => {
try {
// const file = b64toBlob('abc');
const b = 'UklGRmgSAAB......';
let bufferObj = Buffer.from(b, "base64");
console.log("bufferObj", bufferObj) ---> shows buffer data
const options = {
files: {
file1: bufferObj,
},
params: {
steps: {
// You can have many Steps. In this case we will just resize any inputs (:original)
resize: {
use: ':original',
robot: '/image/resize',
result: true,
width: 75,
height: 75,
},
},
// OR if you already created a template, you can use it instead of "steps":
// template_id: 'YOUR_TEMPLATE_ID',
},
waitForCompletion: true, // Wait for the Assembly (job) to finish executing before returning
}
const status = await transloadit.createAssembly(options)
if (status.results.resize) {
console.log('✅ Success - Your resized image:', status.results.resize[0].ssl_url)
} else {
console.log(
"❌ The Assembly didn't produce any output. Make sure you used a valid image file"
)
}
} catch (err) {
console.error('❌ Unable to process Assembly.', err)
if (err.assemblyId) {
console.error(`💡 More info: https://transloadit.com/assemblies/${err.assemblyId}`)
}
}
})()