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
feat(docs): Firebase Storage docs #902
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to go run to a meeting, but I'm about two third of the way done and figured I'd send you what I have so far. Overall, the content looks good. Mainly just have minor suggestions around styling and formatting.
|
||
* [Overview](#overview) | ||
* [API Summary](#api-summary) | ||
* [Uploading files](#uploading-files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other guide pages use all-caps for the section titles. Please update these to make them consistent.
## Overview | ||
|
||
Firebase provides [a hosted binary storage service](https://firebase.google.com/docs/storage/) | ||
which enables you to store and retrieve user-generated content like images, audio and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add Oxford comma after audio
since we use it elsewhere.
video directly from the Firebase client SDK. | ||
|
||
Binary files are stored in a Firebase Storage bucket, not in the Realtime Database. | ||
The file files in your bucket are stored in a hierarchical structure, just like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/file files/files
in the Realtime Database. | ||
|
||
To use the Firebase Storage binding, first [create a Firebase Storage reference](https://firebase.google.com/docs/storage/web/create-reference). | ||
Then using this reference, pass it into the `$firebaseStorage` service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Then using/Then, using
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, replace the closing period with a colon.
// inject $firebaseStorage into our controller | ||
function SampleCtrl($firebaseStorage) { | ||
// create a Firebase Storage Reference for the $firebaseStorage binding | ||
var storageRef = firebase.storage().ref('userProfiles/physicsmarie'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double quotes.
var storageRef = firebase.storage().ref('userProfiles/physicsmarie'); | ||
var storage = $firebaseStorage(storageRef); | ||
} | ||
SampleCtrl.$inject = ["$firebaseStorage"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need this line? Also, can we make this style consistent with how we define the module and controller elsewhere in the docs (e.g. here)?
|
||
| Method | Description | | ||
| ------------- | ------------- | | ||
| [`$progress(callback)`](/docs/reference.md#uploadtask-progress) | Calls the provided callback function whenever there is an update in the progress of the file uploading. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Links for all of these methods are broken. It looks like they don't need a leading "uploadtask-".
| Method | Description | | ||
| ------------- | ------------- | | ||
| [`$progress(callback)`](/docs/reference.md#uploadtask-progress) | Calls the provided callback function whenever there is an update in the progress of the file uploading. | | ||
| [`$error(callback)`](/docs/reference.md#uploadtask-error) | Calls the provided callback function when there is an error uploading the file | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add period to end of description.
| [`$cancel()`](/docs/reference.md#uploadtask-cancel) | Cancels the upload. | | ||
| [`$pause()`](/docs/reference.md#uploadtask-pause) | Pauses the upload. | | ||
| [`$snapshot()`](/docs/reference.md#uploadtask-$snapshot) | Returns the [current immutable view of the task](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress) at the time the event occurred. | | ||
| [`then(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when the upload is complete. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Upload Task/UploadTask
(and add backticks around it)
s/promise/Promise
(and add backticks around it)
s/The callback/This callback
| [`$pause()`](/docs/reference.md#uploadtask-pause) | Pauses the upload. | | ||
| [`$snapshot()`](/docs/reference.md#uploadtask-$snapshot) | Returns the [current immutable view of the task](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress) at the time the event occurred. | | ||
| [`then(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when the upload is complete. | | ||
| [`catch(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when an error occurs. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on the comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, all done with my first pass.
| [`catch(callback)`](/docs/reference.md#uploadtask-then) | An Upload Task implements a promise like interface. The callback is called when an error occurs. | | ||
|
||
## Displaying images with the `firebase-src` directive | ||
AngularFire provides a directive that displays a file with any `src` compatible element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line after the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: src
-compatible
## Displaying images with the `firebase-src` directive | ||
AngularFire provides a directive that displays a file with any `src` compatible element. | ||
|
||
Instead of using the tradional `src` attribute, use `firebase-src`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just make this part of the previous paragraph?
``` | ||
|
||
## Retrieving files from the template | ||
AngularFire does not provide a directive for retrieving a upload file. However, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line after header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/a upload/an uploaded
|
||
## Retrieving files from the template | ||
AngularFire does not provide a directive for retrieving a upload file. However, | ||
the below directive is basic but provides a baseline to work off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: get rid of "is basic but" and replace the closing period with a colon.
scope: { | ||
onChange: "=" | ||
}, | ||
template: "<input type="file" name="file" class="inputfile" /><label><ng-transclude></ng-transclude></label>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity, I would suggest dropping the class
attribute as it isn't really required for this example to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Within the template, you should use single quotes or escape the double quotes.
var asString = $scope.storage.$toString(); | ||
``` | ||
|
||
## Upload Task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have three #
characters.
var uploadTask = $scope.storage.$put(htmlFile, { contentType: 'text/html' }); | ||
``` | ||
|
||
## $putString(string, format, metadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All methods directly off of $firebaseStorage
should have three #
characters, not two.
var uploadTask = $scope.storage.$put(htmlFile, { contentType: 'text/html' }); | ||
``` | ||
|
||
## $progress(callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All headers under Upload Task
should have four #
characters, not two.
$scope.bytesTransferred = uploadTask.$snapshot.bytesTransferred; | ||
``` | ||
|
||
## Upload Task then() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be then()?
}); | ||
``` | ||
|
||
## Upload Task catch() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be catch()?
Oh this is perfect, You guys are soon done with it and I just cant wait! Keep up the good work guys, you are the best |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are good after a few last edits.
| [`then(callback)`](/docs/reference.md#then) | An `UploadTask` implements a `Promise` like interface. This callback is called when the upload is complete. | | ||
| [`catch(callback)`](/docs/reference.md#catch) | An `UploadTask` implements a `Promise` like interface. This callback is called when an error occurs. | | ||
|
||
## Displaying images with the `firebase-src` directive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be title-case.
<img firebase-src="{{ userProfileId }}" /> | ||
``` | ||
|
||
## Retrieving files from the template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be title-case.
@@ -0,0 +1,147 @@ | |||
# Uploading & Downloading Binary Content | AngularFire Guide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link to this page needs to get added to https://github.com/firebase/angularfire/blob/master/docs/guide/README.md. I think putting it as #4 (in between the Database and Auth sections) makes the most sense. Also, we need to make sure to update the link at the end of guide section #3 now links to this guide and, at the end of this guide, link to guide section #5 (which will now be the Auth section).
|
||
| Method | Description | | ||
| ------------- | ------------- | | ||
| [`$put(file, metadata)`](/docs/reference.md#putfile-metadata) | Uploads file to configured path with optional metadata. Returns an AngularFire wrapped `UploadTask`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's link UploadTask
to #upload-task-api-summary
everywhere in this API summary (four instances).
|
||
## Retrieving files from the template | ||
|
||
AngularFire does not provide a directive for retrieving an upload file. However, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/upload/uploaded
Returns a promise fulfilled with the updated metadata. | ||
|
||
```js | ||
var updateData = { contenType: 'text/plain' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double quotes.
|
||
```js | ||
var updateData = { contenType: 'text/plain' }; | ||
$scope.storage.$updateMetadata(updateData).then(function(completeMetadata) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/completeMetadata/updatedMetadata
|
||
```js | ||
$scope.storage.$delete().then(function() { | ||
console.log('successfully deleted!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use double quotes.
### Upload Task | ||
|
||
The [`$firebaseStorage()`](#firebasestorage) service returns an AngularFire wrapped [`UploadTask`](https://firebase.google.com/docs/reference/js/firebase.storage#uploadtask) when uploading binary content | ||
using the [`$put()`]($putfile-metadata) and [`$putString()`](#putstringstring-format-metadata) methods. This task is used for [monitoring](https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_progress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link for $put()
404s.
and [managing](https://firebase.google.com/docs/storage/web/upload-files#manage_uploads) uploads. | ||
|
||
```js | ||
var htmlFile = new Blob(["<html></html>"], {type : "text/html"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on comment above regarding padding spaces.
Documentation for the
$firebaseStorage()
service andfirebase-src
directive.