I am trying to create a small uploader from my app, to upload a single image to transloadit.
I’ve referred to documentations and this below example ( Transloadit — Uppy )
I have a specific path, and doesn’t need webcam/instagram source modules. ( ‘./assets/my_logo_v2.png’ ) , how do I provide this path inside the below code. without using instagram or camera modules?
Also, I have a authKey and authSecret from Transloadit, instead of TRANSLOADIT_API_KEY
I don’t find a place to provide these two.
const Uppy = require('@uppy/core')
const Dashboard = require('@uppy/transloadit')
const Webcam = require('@uppy/webcam')
const Transloadit = require('@uppy/transloadit')
const Instagram = require('@uppy/instagram')
const uppy = new Uppy({
debug: true,
autoProceed: false,
restrictions: {
maxFileSize: 1024 * 1024 * 1024,
maxNumberOfFiles: 2,
minNumberOfFiles: 1,
allowedFileTypes: ['image/*']
},
locale: {
strings: {
youCanOnlyUploadFileTypes: 'You can only upload images'
}
}
})
uppy
.use(Transloadit, {
params: {
auth: {
key: YOUR_TRANSLOADIT_API_KEY
},
// It’s more secure to use a template_id and enable
// Signature Authentication
steps: {
resize: {
robot: '/image/resize',
width: 250,
height: 250,
resize_strategy: 'fit',
text: [
{
text: '© Transloadit.com',
size: 12,
font: 'Ubuntu',
color: '#eeeeee',
valign: 'bottom',
align: 'right',
x_offset: 16,
y_offset: -10
}
]
}
}
},
waitForEncoding: true
})
.use(Instagram, { target: Dashboard, companionUrl: 'https://api2.transloadit.com/companion', companionAllowedHosts: /\.transloadit\.com$/ })
.use(Dashboard, {
inline: true,
maxHeight: 400,
target: '#uppy-dashboard-container',
note: 'Images and video only, 1–2 files, up to 1 MB'
})
.use(Webcam, { target: Dashboard })
.on('transloadit:result', (stepName, result) => {
const file = uppy.getFile(result.localId)
var resultContainer = document.createElement('div')
resultContainer.innerHTML = `
<div>
<h3>Name: ${file.name}</h3>
<img src="${result.ssl_url}" /> <br />
<a href="${result.ssl_url}">View</a>
</div>
`
document
.getElementById('uppy-transloadit-result')
.appendChild(resultContainer)
})