Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding firebase storage #226

Merged
merged 51 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
3850ca3
Added firebase-storage-behavior.html
tjmonsi Jul 7, 2016
72c1d5c
Added firebase-storage and fixed firebase-storage-behavior
tjmonsi Jul 7, 2016
24fc775
Fixed a bug in firebase-storage and added it in polymerfire
tjmonsi Jul 7, 2016
1074832
Fixed some bugs on the multiple uploads and added a demo
tjmonsi Jul 8, 2016
8d30ef5
Fixed delete
tjmonsi Jul 8, 2016
edbab3a
Current stable version done
tjmonsi Jul 8, 2016
d059a33
Added fix on firebase-storage-behavior.html
tjmonsi Jul 9, 2016
d2b3b6a
Updated firebase-storage-behavior and firebase-storage
tjmonsi Feb 14, 2017
b6e3bc7
Removed conflict
tjmonsi Feb 14, 2017
4a4143b
Resolved conflicts for PR
tjmonsi Feb 14, 2017
4f51cf7
Merge branch 'master' into adding-firebase-storage
tjmonsi Feb 14, 2017
cebbc8f
Reverting (adding new line)
tjmonsi Feb 14, 2017
a574f7c
changed to firebase-storage-multiupload
tjmonsi Apr 20, 2017
498c745
Merge
tjmonsi Apr 20, 2017
f884838
added ref and task
tjmonsi Apr 21, 2017
d238acd
Be consistent
tjmonsi Apr 21, 2017
9f2646e
being consistent
tjmonsi Apr 21, 2017
80abcf6
added putstring
tjmonsi Apr 21, 2017
31b45e2
renamed to uploadTask
tjmonsi Apr 21, 2017
9334f48
added documentation
tjmonsi May 4, 2017
41feaf6
Merge remote-tracking branch 'refs/remotes/firebase/master' into addi…
tjmonsi May 24, 2017
208b61e
fixing conflicts
tjmonsi May 24, 2017
03fb708
fixed the __pathChanged to check if storage has been initialized
tjmonsi May 24, 2017
feb8b05
fixed demo
tjmonsi May 24, 2017
12c0baa
added toString for gs
tjmonsi May 24, 2017
b466ab8
Add Cloud Storage URI to demo
FluorescentHallucinogen May 25, 2017
5d79cf1
Add paper-progress and paper-toast to devDependencies
FluorescentHallucinogen May 25, 2017
41b65ce
Add Cloud Storage URI to docs
FluorescentHallucinogen May 25, 2017
5603e0b
Fix 'string' property description
FluorescentHallucinogen May 25, 2017
b213bc9
Rename 'string' property to 'storage-uri'
FluorescentHallucinogen May 25, 2017
11e02e8
Fix mistake
FluorescentHallucinogen May 25, 2017
dcd3695
Merge pull request #4 from FluorescentHallucinogen/patch-1
tjmonsi May 25, 2017
b873894
Merge branch 'master' into adding-firebase-storage
tjmonsi May 25, 2017
58462a6
added fixes
tjmonsi May 26, 2017
19e44b3
before squish
tjmonsi May 26, 2017
6928d4a
change toString to toGsString
tjmonsi Jun 1, 2017
53810ab
Merge branch 'master' into adding-firebase-storage
tjmonsi Jun 1, 2017
bc5de7b
revert
tjmonsi Jun 1, 2017
1f4f226
Based on #214
tjmonsi Jun 2, 2017
7f5fa12
Fixed storage-uri
tjmonsi Jun 2, 2017
bd82b23
Fixed no-auto/upload and added no-auto demo
tjmonsi Jun 2, 2017
3518a98
Rename files
FluorescentHallucinogen Jun 21, 2017
888e095
Remove unused code
FluorescentHallucinogen Jun 21, 2017
8ee7562
Cosmetic fixes
FluorescentHallucinogen Jun 21, 2017
0d98ba8
Remove isImage
FluorescentHallucinogen Jun 21, 2017
8d7be4e
Merge pull request #5 from FluorescentHallucinogen/adding-firebase-st…
tjmonsi Jun 22, 2017
a581995
Merge branch 'adding-firebase-storage' of github.com:tjmonsi/polymerfire
christophe-g Jul 6, 2017
d756566
fixed name of "firebase-storage-multiupload-demo" : multiple componen…
christophe-g Jul 6, 2017
b2a744d
fixed "ref.path" issue when putting files: as ref was already pointin…
christophe-g Jul 6, 2017
3d47c31
added byte transferred in demo
christophe-g Jul 6, 2017
c7ec1f2
Merge pull request #6 from christophe-g/fix-upload-path
tjmonsi Jul 8, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#1 - 2",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0",
"web-component-tester": "Polymer/web-component-tester#^6.0.0"
"web-component-tester": "Polymer/web-component-tester#^6.0.0",
"paper-progress": "PolymerElements/paper-progress#1 - 2",
"paper-toast": "PolymerElements/paper-toast#1 - 2"
},
"variants": {
"1.x": {
Expand All @@ -37,7 +39,9 @@
"devDependencies": {
"iron-component-page": "PolymerElements/iron-component-page#^1.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"paper-progress": "PolymerElements/paper-progress#^1.0",
"paper-toast": "PolymerElements/paper-toast#^1.0"
},
"resolutions": {
"webcomponentsjs": "^0.7"
Expand Down
22 changes: 22 additions & 0 deletions demo/firebase-storage-auto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<!--
@license
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://github.com/firebase/polymerfire/blob/master/LICENSE
-->

<html>
<head>
<meta charset="utf-8">
<title>firebase-storage-multiupload demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="./firebase-storage-multiupload-auto.html">

</head>
<body>
<firebase-storage-multiupload-auto></firebase-storage-multiupload-auto>
</body>
</html>
194 changes: 194 additions & 0 deletions demo/firebase-storage-multiupload-auto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
<!--
@license
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://github.com/firebase/polymerfire/blob/master/LICENSE
-->

<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../paper-progress/paper-progress.html">
<link rel="import" href="../../paper-toast/paper-toast.html">
<link rel="import" href="../polymerfire.html">

<dom-module id="firebase-storage-multiupload-auto">
<template>
<firebase-app
auth-domain="polymerfire-test-6abc0.firebaseapp.com"
database-url="https://polymerfire-test-6abc0.firebaseio.com"
api-key="AIzaSyBxZI1BAgX9obocHQw_yhmHV9BIOpaNWZo"
storage-bucket="polymerfire-test-6abc0.appspot.com">
</firebase-app>

<firebase-auth
id="auth"
user="{{user}}"
provider="google"
on-error="catchError">
</firebase-auth>

<button on-tap="signIn">Sign In</button> <br>

<template is="dom-if" if="{{user}}">
<firebase-storage-multiupload
id="fs"
path="/users/{{user.uid}}/files"
files="[[files]]"
upload-tasks="{{uploadedFiles}}"
on-error="catchError"
force-unique
auto>
</firebase-storage-multiupload>

<input id="file-uploader" type="file" on-change="onFileUpload" multiple /> <br>

<hr>

<template is="dom-repeat" items="[[uploadedFiles]]">
<div style="padding: 20px">
<firebase-storage-upload-task
task="[[item]]"
id="task-[[index]]"
bytes-transferred="{{item.bytesTransferred}}"
total-bytes="{{item.totalBytes}}"
state="{{item.state}}"
download-url="{{item.downloadUrl}}"
metadata="{{item.metadata}}"
path="{{item.path}}">
</firebase-storage-upload-task>

path from snapshot: [[item.snapshot.ref.fullPath]] <br>
path from upload-task: [[item.path]] <br>
bytes transferred: [[item.bytesTransferred]] <br>
storage uri: [[gsUri]] <br>
state: [[item.state]] <br>
metadata-contentType: [[item.metadata.contentType]] <br>

<br>

<template is="dom-if" if="[[!isEqual(item.state, 'success')]]">
<paper-progress
value="{{item.bytesTransferred}}"
min="0"
max="{{item.totalBytes}}">
</paper-progress>
</template>

<br>

<template is="dom-if" if="{{isEqual(item.state, 'success')}}">
<firebase-storage-ref
path="{{item.path}}"
storage-uri="{{gsUri}}"
id="ref-[[index]]"
metadata="{{item.refMetadata}}"
download-url="{{item.refDownloadUrl}}">
</firebase-storage-ref>

<a href="{{item.refDownloadUrl}}">{{item.refDownloadUrl}}</a> <br>

<button on-tap="download" value="{{index}}">Download</button>

<button on-tap="deleteFile" value="{{index}}">Delete</button>
</template>

<template is="dom-if" if="[[!isEqual(item.state, 'success')]]">
<template is="dom-if" if="[[isEqual(item.state, 'running')]]">
<button on-tap="cancel" value="{{index}}">Cancel</button>
<button on-tap="pause" value="{{index}}">Pause</button>
</template>

<template is="dom-if" if="[[isEqual(item.state, 'paused')]]">
<button on-tap="resume" value="{{index}}">Resume</button>
</template>
</template>

<br>
</div>
</template>
</template>

<paper-toast id="toaster"></paper-toast>
</template>

<script>
(function() {
'use strict';

Polymer({
is: 'firebase-storage-multiupload-auto',

properties: {
user: Object,

files: {
type: Array,
notify: true,
value: [],
},

uploadTasks: {
type: Array,
observer: '_uploadTasksChanged'
},

uploadedFiles: {
type: Array,
}
},

catchError(e) {
this.$$('#toaster').show({
text: e.detail.message
});
},

cancel(e) {
this.$$('#task-' + e.target.value).cancel();
},

resume(e) {
this.$$('#task-' + e.target.value).resume();
},

pause(e) {
this.$$('#task-' + e.target.value).pause();
},

download(e) {
this.$$('#ref-' + e.target.value).getDownloadURL().then(function(d) {
console.log(d)
window.open(d, '_blank')
})
},

deleteFile(e) {
this.$$('#ref-' + e.target.value).delete().then(function(d) {
console.log(d)
})
},

_uploadTasksChanged(uploadTasks) {
console.log(uploadTasks);
},

_uploadedFilesChanged(uploadedFiles) {
console.log(uploadedFiles);
},

onFileUpload(e) {
this.files = e.target.files;
console.log(this.files)
},

isEqual(a, b) {
return a === b;
},

signIn: function() {
this.$.auth.signInAnonymously();
}
});
})();
</script>
</dom-module>
Loading