Storage support for local disk (#165)
* Storage support for local disk * UI change ai feature page --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
20
resources/js/plugins/vapor.js
vendored
20
resources/js/plugins/vapor.js
vendored
@@ -15,6 +15,26 @@ Vue.mixin({
|
||||
* Store a file in S3 and return its UUID, key, and other information.
|
||||
*/
|
||||
async storeFile (file, options = {}) {
|
||||
if(!window.config.s3_enabled) { // If not s3 then upload to local temp
|
||||
if (typeof options.progress === 'undefined') {
|
||||
options.progress = () => {}
|
||||
}
|
||||
const cleanAxios = axios.create()
|
||||
let formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const response = await cleanAxios.post('/upload-file', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
onUploadProgress: (progressEvent) => {
|
||||
options.progress(progressEvent.loaded / progressEvent.total)
|
||||
}
|
||||
})
|
||||
|
||||
response.data.extension = file.name.split('.').pop()
|
||||
return response.data
|
||||
}
|
||||
|
||||
const response = await axios.post(options.signedStorageUrl ? options.signedStorageUrl : '/vapor/signed-storage-url', {
|
||||
bucket: options.bucket || '',
|
||||
content_type: options.contentType || file.type,
|
||||
|
||||
Reference in New Issue
Block a user