SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Building Photo Uploader
with HTML5
by Hieupv2
@Lifetime Technologies Co.,ltd
Duy Tan Geeks #2 Jan 15th 2014
@mrhieu @mrhieu
hieupv2@gmail.com
PHP developer
Front-end developer
Ruby On Rails beginner
Contact
About Me
About Lifetime Technologies Co.,ltd
100% foreign-owned
IT industry
61 members
What we do:
Web application
Mobile application
Contact
9F, Viet A building, Cau Giay district, Hanoi, Vietnam
www.lifetimetech.vn
START
Ancient photo uploader
and “MODERN” one
Challenges
● Drag ‘n’ drop
● Limit of 10 files, 10MB each
● Multiple upload
● Instant photo thumbnail, file info
● Extract EXIF data at CLIENT-side
● Extract GPS data and display (on a map)
Challenges (cont)
● Form data for each photo
● Add, remove photos to upload
● Display upload progress
Drag and drop
- Javascript API
- Event-based
- Listening for Dragging Events: dragstart,
dragenter, drop, dragend
domElement.addEventListener('dragdrop',
handleDropStart, false);
function handleDrop(e) {
var files = e.dataTransfer.files;
Reference:www.html5rocks.com/en/tutorials/dnd/basics/
Demo: http://html5demos.com/dnd-upload
Limit of 10 files, 10MB each
- Count
- File reader API
var files = e.dataTransfer.files; // FileList object.
// files is a FileList of File objects. List some
properties.
for (var i = 0, f; f = files[i]; i++) {
console.log(f.name, f.type, f.size, f.
lastModifiedDate)
}
Reference:www.html5rocks.com/en/tutorials/file/dndfiles/
Multiple Upload
Implementation of XHR2 object
- Append form data “on the fly”
- Cross-origin requests sharing (CORS)
- Uploading progress events
- Chunk uploading/downloading binary data
Reference:www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-formdata
Instant thumbnail, file info
- File reader API (again)
- Asynchronous
var reader = new FileReader();
// Closure to capture the file information.
reader.onload = (function(theFile) {
return function(e) {
// Render thumbnail.
console.log(e.target.result);
}
})(file);
reader.readAsDataURL(f);
Instant thumbnail, file info (cont)
imageData:
data:image/jpeg;base64,
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMC
AgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYID
AoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRU
VDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFB
QkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFB
QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB
QUFBQUFBT/wAARCAL4BHQDASIAAhEBAxEB/8
QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQ
FBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9
AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0Kxw
RVS0fAkM2JyggkKFhcYGRol………………………..
Extract EXIF data
- File reader API (agaiiin)
- At the first 128kb of the image
- Standardized data structure
@.@
Reference: http://code.flickr.net/2012/06/01/parsing-exif-client-side-using-
javascript-2/
Extract EXIF data (cont)
Extract GPS data and display (on a
map)
- Extract from Exif Data
- Properties: .GPSLatitude
.GPSLongitude
- Googlemaps Javascript API v3
Add, remove specifics photo
- Tricky
- Add
- Remove
Upload progress
- XHR2
xhr.upload.onprogress = function(e) {
if (e.lengthComputable) {
progressBar.value = (e.loaded / e.total) * 100;
progressBar.textContent = progressBar.value;
// Fallback for unsupported browsers.
}
}
Reference:www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-blob
Put them all together
Jquery
Jquery File Upload github.com/blueimp/jQuery-File-Upload
Canvasresize, Exif github.com/gokercebeci/canvasResize
Javascript Template Engine
github.com/blueimp/JavaScript-Templates
Bootstrap
Datepicker, Timepicker
Others.
http://mrhieu.github.io/500pxupload/
Wait a minute...
One more thing
Display
INCOMPLETED
uploaded
photos
Upload Processing...
One more thing
● It takes (long) time for server’s manipulation
- Re-sizing
- Indexing
- Generating location (place) info...
● No extra thumbnail photo stored on server
side
● Automatically fetch “real” photo once
processes have been finished.
HTML5 Web storage
- 5MB
- Key-value
- Session Storage / Local Storage
if (window.sessionStorage) {
//..
sessionStorage.setItem('photo_' + data.files[0].
name.substring(0, 20), imageData);
}
sessionStorage.getItem(<key>);
Reference: http://www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-blob
Clever Collaboration
Server
- API: whether photos are all finished
- (Push technology)
Client
- Continuous request (per 5s) / Push
technology
- Retrieve processed photos
- Remove web storage records
So what ?
It just works !
mrhieu.github.io
/500pxupload
want more
?
ありがと
See this online: http://goo.gl/nQ0Fid

Mais conteúdo relacionado

Semelhante a Modern photo uploader

Utilizing HTML5 APIs
Utilizing HTML5 APIsUtilizing HTML5 APIs
Utilizing HTML5 APIsIdo Green
 
Modern Web Applications Utilizing HTML5 APIs
Modern Web Applications Utilizing HTML5 APIsModern Web Applications Utilizing HTML5 APIs
Modern Web Applications Utilizing HTML5 APIsIdo Green
 
Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?Andy Davies
 
Asynchronous Programming with JavaScript
Asynchronous Programming with JavaScriptAsynchronous Programming with JavaScript
Asynchronous Programming with JavaScriptWebF
 
Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsJohannes Weber
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorialjbarciauskas
 
More android code puzzles
More android code puzzlesMore android code puzzles
More android code puzzlesDanny Preussler
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patternsStoyan Stefanov
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07Frédéric Harper
 
ConFoo 2016 - Mum, I want to be a Groovy full-stack developer
ConFoo 2016 - Mum, I want to be a Groovy full-stack developerConFoo 2016 - Mum, I want to be a Groovy full-stack developer
ConFoo 2016 - Mum, I want to be a Groovy full-stack developerIván López Martín
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Ido Green
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!Chang W. Doh
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datosphilogb
 
Creating an Effective Mobile API
Creating an Effective Mobile API Creating an Effective Mobile API
Creating an Effective Mobile API Nick DeNardis
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSphilogb
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance PatternsStoyan Stefanov
 
Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Jon Arne Sæterås
 
Developing advanced universal apps using html & js
Developing advanced universal apps using html & jsDeveloping advanced universal apps using html & js
Developing advanced universal apps using html & jsSenthamil Selvan
 

Semelhante a Modern photo uploader (20)

Seti 09
Seti 09Seti 09
Seti 09
 
Utilizing HTML5 APIs
Utilizing HTML5 APIsUtilizing HTML5 APIs
Utilizing HTML5 APIs
 
Modern Web Applications Utilizing HTML5 APIs
Modern Web Applications Utilizing HTML5 APIsModern Web Applications Utilizing HTML5 APIs
Modern Web Applications Utilizing HTML5 APIs
 
Http/2 - What's it all about?
Http/2  - What's it all about?Http/2  - What's it all about?
Http/2 - What's it all about?
 
Asynchronous Programming with JavaScript
Asynchronous Programming with JavaScriptAsynchronous Programming with JavaScript
Asynchronous Programming with JavaScript
 
Progressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & LearningsProgressive Web Apps - Intro & Learnings
Progressive Web Apps - Intro & Learnings
 
DWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A TutorialDWR, Hibernate and Dojo.E - A Tutorial
DWR, Hibernate and Dojo.E - A Tutorial
 
More android code puzzles
More android code puzzlesMore android code puzzles
More android code puzzles
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
HTML pour le web mobile, Firefox OS - Devfest Nantes - 2014-11-07
 
ConFoo 2016 - Mum, I want to be a Groovy full-stack developer
ConFoo 2016 - Mum, I want to be a Groovy full-stack developerConFoo 2016 - Mum, I want to be a Groovy full-stack developer
ConFoo 2016 - Mum, I want to be a Groovy full-stack developer
 
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
 
ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!ServiceWorker: New game changer is coming!
ServiceWorker: New game changer is coming!
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
Creating an Effective Mobile API
Creating an Effective Mobile API Creating an Effective Mobile API
Creating an Effective Mobile API
 
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJSJavaScript para Graficos y Visualizacion de Datos - BogotaJS
JavaScript para Graficos y Visualizacion de Datos - BogotaJS
 
JavaScript Performance Patterns
JavaScript Performance PatternsJavaScript Performance Patterns
JavaScript Performance Patterns
 
Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013
 
Developing advanced universal apps using html & js
Developing advanced universal apps using html & jsDeveloping advanced universal apps using html & js
Developing advanced universal apps using html & js
 

Mais de Duy Tan Geek

Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load BalancingDuy Tan Geek
 
Cloud - FOSS & Challenge
Cloud - FOSS & ChallengeCloud - FOSS & Challenge
Cloud - FOSS & ChallengeDuy Tan Geek
 
AWS, is it interesting?
AWS, is it interesting?AWS, is it interesting?
AWS, is it interesting?Duy Tan Geek
 
Cloud DC Transforming
Cloud DC TransformingCloud DC Transforming
Cloud DC TransformingDuy Tan Geek
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testingDuy Tan Geek
 
Practical TDD in Septeni Technology
Practical TDD in Septeni TechnologyPractical TDD in Septeni Technology
Practical TDD in Septeni TechnologyDuy Tan Geek
 
Build Quality In with TDD
Build Quality In with TDDBuild Quality In with TDD
Build Quality In with TDDDuy Tan Geek
 
Sharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfSharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfDuy Tan Geek
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x EngineDuy Tan Geek
 
HTML5 mobile games
HTML5 mobile gamesHTML5 mobile games
HTML5 mobile gamesDuy Tan Geek
 
Game engine introduction and approach
Game engine introduction and approachGame engine introduction and approach
Game engine introduction and approachDuy Tan Geek
 
10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese10 things you need to know about doing business with Japanese
10 things you need to know about doing business with JapaneseDuy Tan Geek
 
Enjoy Japanese work style
Enjoy Japanese work styleEnjoy Japanese work style
Enjoy Japanese work styleDuy Tan Geek
 
A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!Duy Tan Geek
 
Introduction to pmp
Introduction to pmpIntroduction to pmp
Introduction to pmpDuy Tan Geek
 
Beyond project management
Beyond project managementBeyond project management
Beyond project managementDuy Tan Geek
 
The way to set automation testing
The way to set automation testingThe way to set automation testing
The way to set automation testingDuy Tan Geek
 
Quality Management Introduction
Quality Management IntroductionQuality Management Introduction
Quality Management IntroductionDuy Tan Geek
 
Techniques in black box testing
Techniques in black box testingTechniques in black box testing
Techniques in black box testingDuy Tan Geek
 

Mais de Duy Tan Geek (20)

Amazon Elastic Load Balancing
Amazon Elastic Load BalancingAmazon Elastic Load Balancing
Amazon Elastic Load Balancing
 
Cloud - FOSS & Challenge
Cloud - FOSS & ChallengeCloud - FOSS & Challenge
Cloud - FOSS & Challenge
 
AWS, is it interesting?
AWS, is it interesting?AWS, is it interesting?
AWS, is it interesting?
 
Cloud DC Transforming
Cloud DC TransformingCloud DC Transforming
Cloud DC Transforming
 
Becoming a better programmer - unit testing
Becoming a better programmer - unit testingBecoming a better programmer - unit testing
Becoming a better programmer - unit testing
 
Practical TDD in Septeni Technology
Practical TDD in Septeni TechnologyPractical TDD in Septeni Technology
Practical TDD in Septeni Technology
 
Build Quality In with TDD
Build Quality In with TDDBuild Quality In with TDD
Build Quality In with TDD
 
Sharing bridge SE working experience of myself
Sharing bridge SE working experience of myselfSharing bridge SE working experience of myself
Sharing bridge SE working experience of myself
 
Game development with Cocos2d-x Engine
Game development with Cocos2d-x EngineGame development with Cocos2d-x Engine
Game development with Cocos2d-x Engine
 
HTML5 mobile games
HTML5 mobile gamesHTML5 mobile games
HTML5 mobile games
 
Game engine introduction and approach
Game engine introduction and approachGame engine introduction and approach
Game engine introduction and approach
 
10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese10 things you need to know about doing business with Japanese
10 things you need to know about doing business with Japanese
 
Enjoy Japanese work style
Enjoy Japanese work styleEnjoy Japanese work style
Enjoy Japanese work style
 
A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!A cup of coffee worth 10 dollars is what we are going to sell!
A cup of coffee worth 10 dollars is what we are going to sell!
 
Leader ship value
Leader ship valueLeader ship value
Leader ship value
 
Introduction to pmp
Introduction to pmpIntroduction to pmp
Introduction to pmp
 
Beyond project management
Beyond project managementBeyond project management
Beyond project management
 
The way to set automation testing
The way to set automation testingThe way to set automation testing
The way to set automation testing
 
Quality Management Introduction
Quality Management IntroductionQuality Management Introduction
Quality Management Introduction
 
Techniques in black box testing
Techniques in black box testingTechniques in black box testing
Techniques in black box testing
 

Último

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Último (20)

Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

Modern photo uploader

  • 1. Building Photo Uploader with HTML5 by Hieupv2 @Lifetime Technologies Co.,ltd Duy Tan Geeks #2 Jan 15th 2014
  • 2. @mrhieu @mrhieu hieupv2@gmail.com PHP developer Front-end developer Ruby On Rails beginner Contact About Me
  • 3. About Lifetime Technologies Co.,ltd 100% foreign-owned IT industry 61 members What we do: Web application Mobile application Contact 9F, Viet A building, Cau Giay district, Hanoi, Vietnam www.lifetimetech.vn
  • 7. Challenges ● Drag ‘n’ drop ● Limit of 10 files, 10MB each ● Multiple upload ● Instant photo thumbnail, file info ● Extract EXIF data at CLIENT-side ● Extract GPS data and display (on a map)
  • 8. Challenges (cont) ● Form data for each photo ● Add, remove photos to upload ● Display upload progress
  • 9. Drag and drop - Javascript API - Event-based - Listening for Dragging Events: dragstart, dragenter, drop, dragend domElement.addEventListener('dragdrop', handleDropStart, false); function handleDrop(e) { var files = e.dataTransfer.files; Reference:www.html5rocks.com/en/tutorials/dnd/basics/ Demo: http://html5demos.com/dnd-upload
  • 10. Limit of 10 files, 10MB each - Count - File reader API var files = e.dataTransfer.files; // FileList object. // files is a FileList of File objects. List some properties. for (var i = 0, f; f = files[i]; i++) { console.log(f.name, f.type, f.size, f. lastModifiedDate) } Reference:www.html5rocks.com/en/tutorials/file/dndfiles/
  • 11. Multiple Upload Implementation of XHR2 object - Append form data “on the fly” - Cross-origin requests sharing (CORS) - Uploading progress events - Chunk uploading/downloading binary data Reference:www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-formdata
  • 12. Instant thumbnail, file info - File reader API (again) - Asynchronous var reader = new FileReader(); // Closure to capture the file information. reader.onload = (function(theFile) { return function(e) { // Render thumbnail. console.log(e.target.result); } })(file); reader.readAsDataURL(f);
  • 13. Instant thumbnail, file info (cont) imageData: data:image/jpeg;base64, /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMC AgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYID AoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRU VDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFB QkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFB QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFB QUFBQUFBT/wAARCAL4BHQDASIAAhEBAxEB/8 QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQ FBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9 AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0Kxw RVS0fAkM2JyggkKFhcYGRol………………………..
  • 14. Extract EXIF data - File reader API (agaiiin) - At the first 128kb of the image - Standardized data structure @.@ Reference: http://code.flickr.net/2012/06/01/parsing-exif-client-side-using- javascript-2/
  • 16. Extract GPS data and display (on a map) - Extract from Exif Data - Properties: .GPSLatitude .GPSLongitude - Googlemaps Javascript API v3
  • 17. Add, remove specifics photo - Tricky - Add - Remove
  • 18. Upload progress - XHR2 xhr.upload.onprogress = function(e) { if (e.lengthComputable) { progressBar.value = (e.loaded / e.total) * 100; progressBar.textContent = progressBar.value; // Fallback for unsupported browsers. } } Reference:www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-blob
  • 19. Put them all together Jquery Jquery File Upload github.com/blueimp/jQuery-File-Upload Canvasresize, Exif github.com/gokercebeci/canvasResize Javascript Template Engine github.com/blueimp/JavaScript-Templates Bootstrap Datepicker, Timepicker Others.
  • 24. One more thing ● It takes (long) time for server’s manipulation - Re-sizing - Indexing - Generating location (place) info... ● No extra thumbnail photo stored on server side ● Automatically fetch “real” photo once processes have been finished.
  • 25. HTML5 Web storage - 5MB - Key-value - Session Storage / Local Storage if (window.sessionStorage) { //.. sessionStorage.setItem('photo_' + data.files[0]. name.substring(0, 20), imageData); } sessionStorage.getItem(<key>); Reference: http://www.html5rocks.com/en/tutorials/file/xhr2/#toc-send-blob
  • 26. Clever Collaboration Server - API: whether photos are all finished - (Push technology) Client - Continuous request (per 5s) / Push technology - Retrieve processed photos - Remove web storage records
  • 27.
  • 28. So what ? It just works ! mrhieu.github.io /500pxupload
  • 30. ありがと See this online: http://goo.gl/nQ0Fid