how can I fetch exifdata(like gps) with filepond? - filepond

I am trying to use filepond for my assignment, but I can't get exifdata from photos.
for example, as I expected
File {name: "KakaoTalk_20210727_153219119.jpg", lastModified: 1627367574529, lastModifiedDate: Tue Jul 27 2021 15:32:54 GMT+0900 (Korean Standard Time), webkitRelativePath: "", size: 2319798, …}
exifdata: {ImageWidth: 4000, ImageHeight: 2252, Make: "samsung", Model: "SM-G988N", Orientation: 1, …}
iptcdata: {}
lastModified: 1627367574529
lastModifiedDate: Tue Jul 27 2021 15:32:54 GMT+0900 (Korean Standard Time) {}
name: "KakaoTalk_20210727_153219119.jpg"
size: 2319798
type: "image/jpeg"
webkitRelativePath: ""
I wanted to get exifdata like this with my filepond code like this but I can't find it :(
file: File
lastModified: 1627367574529
lastModifiedDate: Tue Jul 27 2021 15:32:54 GMT+0900 (Korean Standard Time) {}
name: "KakaoTalk_20210727_153219119.jpg"
size: 2319798
type: "image/jpeg"
webkitRelativePath: ""
_relativePath: ""
I really need gps data for my assginment, how could I get it?
this is Vue-filepond code.
<template>
<div id="test">
<br>
<br>
<br>
<br>
<br>
<file-pond
name="test"
ref="pond"
allowImageExifOrientation = "true"
label-idle="Drop files here..."
allowprocess="false"
v-bind:allow-multiple="true"
accepted-file-types="image/jpeg, image/png"
:server="myServer"
instantUpload ="false"
v-bind:files="myFiles"
v-on:init="handleFilePondInit"
imageTransformOutputStripImageHead = "false"
allowImagePreview="true"
imagePreviewHeight="300px"
#initfile="oninitfile()"
#updatefiles="FilePondUpdateFiles"
/>
<br>
<p style="text-align:center">hi</p>
<div v-for="imageFile in imageFiles" :key="imageFile.name" style="text-align:center;">
<img :src="imageFile.src" alt="" style="width: 200px">
</div>
</div>
</template>
methods: {
handleFilePondInit: function () {
console.log("FilePond has initialized");
// FilePond instance methods are available on `this.$refs.pond`
this.$refs.pond.getFiles();
console.log(this.$refs.pond.getFiles())
},
// 파일 staging시
oninitfile() {
console.log("onInit!")
},
FilePondUpdateFiles(files) {
console.log("기본적인 이미지 검색 방식", this.$refs['pond'].file)
console.log(files)
console.log("onAdd!")
this.imageFiles = files
console.log("총 사진 데이터", this.imageFiles)
}
},
thank you for reading and help, have a nice day !

FilePond doesn't read EXIF data it only corrects the orientation header parameter so images can be oriented correctly on older browsers.
You could use Exif-JS combined with FilePond to read EXIF data.
https://github.com/exif-js/exif-js
Use the beforeAddFile hook to read the EXIF data and add it to the file item.
This is a plain JavaScript example which should be straight forward to port to Vue.
FilePond.create({
beforeAddFile: (fileItem) => new Promise(resolve => {
const success = EXIF.getData(fileItem.file, () => {
fileItem.setMetadata('exifdata', EXIF.getAllTags())
// Added EXIF data to file item, we're done
resolve(true);
})
// Can't read EXIF data, don't add file
if (!success) resolve(false);
})
})

Related

Convert Streaming Files To S3 Vue js to Blade js

Can anyone help me to convert the following code, so instead of putting it in Vue component, I want to put it in script tag in blade. and here is my input tag for uploading file
<input type="file" name="photo" />
Streaming Files To S3
<input type="file" id="file" ref="file">
Vapor.store(this.$refs.file.files[0], {
progress: progress => {
this.uploadProgress = Math.round(progress * 100);
}
}).then(response => {
axios.post('/api/profile-photo', {
uuid: response.uuid,
key: response.key,
bucket: response.bucket,
name: this.$refs.file.files[0].name,
content_type: this.$refs.file.files[0].type,
})
});
I dont knw how to convert the code

Filepond integration with livewire dosen't shows progressBar in percentage like 1% to 100%

I have integrated Filepond in my project, am getting a problem when I upload a file it doesn't show its progress from 1 % to 100% but other things work well and the image view also with no problem. Filepond working fine only issue is that when we upload file in livewire component it doesn't show upload progress in percentage. And I am also using same in my controller which is working fine and also showing a progress in percentage.
Initialization with Alpinjs code:
<div class="col-md-12 pb-3 filepond-box">
#if($label)
<x-form.label name="{{ $name }}" label="{{$label}}" class="col-form-label"></x-form.label>
#endif
<div
class="col-md-12"
wire:ignore
x-data
x-init="
() => {
const pond = FilePond.create($refs.filepond)
pond.setOptions({
filePosterMaxHeight:256,
maxFileSize:'10MB',
allowMultiple:true,
server: {
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
},
#isset($_instance)
process:(fieldName, file, metadata, load, error, progress, abort, transfer, options) => {
#this.upload('{{ $attributes->whereStartsWith('wire:model')->first() }}', file, load, error, progress)
},
#else
process: '/file-upload',
#endisset
#isset($_instance)
revert: (filename, load) => {
#this.removeUpload('{{ $attributes->whereStartsWith('wire:model')->first() }}', filename, load)
},
remove: (source, load, error) => {
#this.remove('{{ $attributes->whereStartsWith('wire:model')->first() }}',source);
load();
},
#endisset
load: (source, load, error, progress, abort, headers) => {
var myRequest = new Request(source);
fetch(myRequest).then(function(response) {
response.blob().then(function(myBlob) {
load(myBlob)
});
});
}
},
files: {{$files}}
});
}"
>
<input type="file" x-ref="filepond" name="{{$name}}" {{$attributes}}/>
</div>
<x-form.error field="{{ $attributes->whereStartsWith('wire:model')->first() }}"></x-form.error>
#if($tooltip)
<div class="file-pond-doted-box-tooltip">
{{$tooltip}}
<div class="file-pond-doted-box-tooltip-arrow"></div>
</div>
#endif

Getting a 500 error back from the server, when using the AJAX function in tabulator, I'm sure the data returned is correct

still battling with all things JS and web. I'm an old server side dinosaur, trying to get up-to-date!
I'm using a js library called Tabulator to build a table from JSON data, in an MVC app. The table is drawing, so I'm confident my Tabular includes are working. My views looks like this:
#{
ViewBag.Title = "Report";
}
<style>
.button{
color: darkgrey;
}
#reportTable {
width: 100%;
font-family: sans-serif;
}
</style>
<h2>Sweep Report</h2>
<br />
<div class="container">
<div class="row">
<div class="input-group input-daterange">
<span class="input-group-addon">From</span>
<span><input id="dateFrom" type="text" class="form-control datepicker" value="#DateTime.Now.AddMonths(-2).ToString("dd/MM/yyyy")"></span>
<span class="input-group-addon">To</span>
<span><input id="dateTo" type="text" class="form-control datepicker" value="#DateTime.Now.ToLocalTime().ToString("dd/MM/yyyy")"></span>
<span><button id="viewButton" onclick="displayData()">View Data</button></span>
<span><button id="fetchButton" onclick="downloadData()">Download CSV</button></span>
</div>
<br />
<div id="reportTable"></div>
</div>
</div>
<script>
$('.datepicker').datepicker({
format: 'dd/mm/yyyy'
});
function displayData()
{
var from = $("#dateFrom").datepicker("getDate");
var to = $("#dateTo").datepicker("getDate");
var fromFormatted = $.datepicker.formatDate("dd/mm/yy", from);
var toFormatted = $.datepicker.formatDate("dd/mm/yy", to);
alert(fromFormatted);
alert(toFormatted);
var table = new Tabulator("#reportTable",{
columns: [
{ title: "Date Completed", field: "DateCompleted", width: 200 },
{ title: "Customer ID", field: "CustomerID" },
{ title: "Certificate #", field: "CertId"},
{ title: "Amount Charged", field: "AmountCharged"},
{ title: "Work Completed", field: "WorkCompleted" },
{ title: "CustomerName", field: "CustomerName" },
],
ajaxURL: '#Url.Action("GetTableData", "Sweeps")', //ajax URL
ajaxParams: { To: toFormatted, From: fromFormatted },
});
}
</script>
All works as expected.
My controller method looks like this, but I don't believe this is the problem, the ret variable is in there, just so I can debug and check the data looks right
public JsonResult GetTableData(DateTime To, DateTime From)
{
SweepRepo repo = new SweepRepo(Utilities.GetConString());
List<SweepReport> report = repo.GetSweepReport(From, To).ToList();
var ret = Json(report);
return ret;
}
The data in ret is right, with the correct column names. The error I am getting is :
DataLoader.js:55 Data Load Error: Response {type: 'basic', url: 'https://localhost:44362/Sweeps/GetTableData?To=12%2F07%2F2022&From=12%2F05%2F2022', redirected: false, status: 500, ok: false, …}body: (...)bodyUsed: falseheaders: Headers {}ok: falseredirected: falsestatus: 500statusText: ""type: "basic"url: "https://localhost:44362/Sweeps/GetTableData?To=12%2F07%2F2022&From=12%2F05%2F2022"[[Prototype]]: ResponsearrayBuffer: ƒ arrayBuffer()blob: ƒ blob()body: (...)bodyUsed: (...)clone: ƒ clone()formData: ƒ formData()headers: (...)json: ƒ json()ok: (...)redirected: (...)status: (...)statusText: (...)text: ƒ text()type: (...)url: (...)constructor: ƒ Response()Symbol(Symbol.toStringTag): "Response"get body: ƒ body()get bodyUsed: ƒ bodyUsed()get headers: ƒ headers()get ok: ƒ ok()get redirected: ƒ redirected()get status: ƒ status()get statusText: ƒ statusText()get type: ƒ type()get url: ƒ url()[[Prototype]]: Object
(anonymous) # DataLoader.js:55
Promise.catch (async)
value # DataLoader.js:52
value # Tabulator.js:279
value # Tabulator.js:149
(anonymous) # Tabulator.js:64
setTimeout (async)
i # Tabulator.js:63
(anonymous) # tabulator.min.js:2
n # TabulatorFull.js:6
displayData # Report:100
onclick # Report:77
I'm using Tabulator as next, I'll implement "downloadData()" and utilise the XLSX built in functionality to download the existing data as an excel file.
Any hints or tips would be greatly appreciated!
Thanks you muchly J

ho to bind img src in file json to my template

Hi I am starting with VueJS but I have a problem how to connect IMG src in my template with URL writing in my file JSON .for example when I have some product and I like to show full logo for each article I need to add URL exists in file JSON to src IMG .how I do that please thank
<img src="info.imglogo" alt="Media Aside" />
<span v-text="info.logotitle"></span>
</template>
var infos = [
{
compteur: 1,
imglogo: "../imgs/theme.jpg",
logotitle: "Themeforest",
title: "Thrive Themes",
description:
"Conversion Focused WordPress Themes & Plugins, built from the ground up to make your entire website convert more of your visitors into subscribers, customers & clients.",
link1: "Visit ThriveTheme",
link2: "Read Review",
url: "../imgs/theme.jpg"
},
{
compteur: 2,
logotitle: "Elegant",
title: "Sub-Ex",
description: "com.goodreads.Tres-Zap",
link1: "Dr",
link2: "Honorable",
url: "../imgs/theme.jpg"
},
];
export default {
data() {
return {
infos: infos
};
},
name: "Home",
components: {}
};
</script>
like this.
<template>
<div v-for="(info, index) in infos" :key="index">
<img :src="info.imglogo" alt="Media Aside" v-if="info.imgLogo != undefined" />
<span v-text="info.logotitle"></span>
</div>
</template>
You can do as follow:
<img :src="info.imglogo" alt="Media Aside" />
Explanation:
If you use variables and not text, you have to prepend your HTML attributes by ":"
Here is a working code. Replace your entire vue file by this one:
<template>
<div>
<div v-for="info in infos" :key="info.compteur">
<img :src="info.imglogo" alt="Media Aside" />
<span v-text="info.logotitle"></span>
</div>
</div>
</template>
<script>
export default {
name: "Home",
components: {},
data() {
return {
infos: [
{
compteur: 1,
imglogo: "../imgs/theme.jpg",
logotitle: "Themeforest",
title: "Thrive Themes",
description:
"Conversion Focused WordPress Themes & Plugins, built from the ground up to make your entire website convert more of your visitors into subscribers, customers & clients.",
link1: "Visit ThriveTheme",
link2: "Read Review",
url: "../imgs/theme.jpg",
},
{
compteur: 2,
logotitle: "Elegant",
title: "Sub-Ex",
description: "com.goodreads.Tres-Zap",
link1: "Dr",
link2: "Honorable",
url: "../imgs/theme.jpg",
},
],
};
},
};
</script>

Dropzone multiple file upload uploads 2 files at a time

I have the following code
HTML
<form action="{{ route('documents.store') }}" method="POST" class="kt-form kt-form--label-right">
#csrf
<div class="kt-portlet__body">
<div class="form-group">
<div class="dropzone dropzone-default dropzone-success" id="documents_upload" style="padding: 0;">
<div class="dropzone-msg dz-message needsclick">
<h3 class="dropzone-msg-title">Drop files here</h3>
</div>
</div>
</div>
</div>
</form>
Javascript
<script type="text/javascript">
$(document).ready(function() {
$('#documents_upload').dropzone({
url: "{{ route('documents.store') }}", // Set the url for your upload script location
paramName: "documents", // The name that will be used to transfer the file
maxFiles: 50,
maxFilesize: 4, // MB
addRemoveLinks: true,
acceptedFiles: "application/msword, application/vnd.ms-excel, application/pdf, image/*, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, image/*",
uploadMultiple: true,
headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}"
},
queuecomplete: function() {
// notify about successful upload
// window.location.replace("{{ route('client.documents.index') }}");
}
});
});
</script>
The problem
It seems like this uploads the documents on chunks, 2 at a time. So if I want to upload 8 files it makes 4 requests, each containing 2 files. I want to upload all at once, is there any easy way I can do this ? This method causes many problems, because the user may upload a large amount of documents and when half of them are ready, he can leave/refresh the page, etc. and he will have to search which documents have been uploaded and which have not.
You need to tell the dropzone to do a parallel upload in the options of your dropzone, by the quantity you want.
<script type="text/javascript">
$(document).ready(function() {
$('#documents_upload').dropzone({
url: "{{ route('documents.store') }}", // Set the url for your upload script location
paramName: "documents", // The name that will be used to transfer the file
maxFiles: 50,
maxFilesize: 4, // MB
addRemoveLinks: true,
acceptedFiles: "application/msword, application/vnd.ms-excel, application/pdf, image/*, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, image/*",
parallelUploads:10,
uploadMultiple: true,
headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}"
},
queuecomplete: function() {
// notify about successful upload
// window.location.replace("{{ route('client.documents.index') }}");
}
});
});
Let me know if it worked!!

Resources