Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Added firebase_storage
  • Loading branch information
goderbauer committed May 11, 2017
commit a70e748ae13290f56056a01edcc588d93e0b69f3
9 changes: 9 additions & 0 deletions packages/firebase_storage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
.atom/
.idea
.packages
.pub/
build/
ios/.generated/
packages
pubspec.lock
26 changes: 26 additions & 0 deletions packages/firebase_storage/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2017, the Flutter project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 8 additions & 0 deletions packages/firebase_storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# firebase_storage

A new flutter plugin project.

## Getting Started

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
12 changes: 12 additions & 0 deletions packages/firebase_storage/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures

/gradle
/gradlew
/gradlew.bat
36 changes: 36 additions & 0 deletions packages/firebase_storage/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
group 'io.flutter.plugins.firebase.storage'
version '1.0-SNAPSHOT'

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}

allprojects {
repositories {
jcenter()
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'

defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-storage:10.2.1'
}
}
1 change: 1 addition & 0 deletions packages/firebase_storage/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1536M
1 change: 1 addition & 0 deletions packages/firebase_storage/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'firebase_storage'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.firebase.storage"
android:versionCode="1"
android:versionName="0.0.1">

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.firebase.storage;

import android.app.Activity;
import android.net.Uri;

import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.OnFailureListener;

import com.google.firebase.FirebaseApp;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;

import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.PluginRegistry.Registrar;

import java.util.Map;
import java.io.File;

/**
* FirebaseStoragePlugin
*/
public class FirebaseStoragePlugin implements MethodCallHandler {
private FirebaseStorage firebaseStorage;

public static void registerWith(Registrar registrar) {
final MethodChannel channel = new MethodChannel(registrar.messenger(), "firebase_storage");
channel.setMethodCallHandler(new FirebaseStoragePlugin(registrar.activity()));
}


private FirebaseStoragePlugin(Activity activity) {
FirebaseApp.initializeApp(activity);
this.firebaseStorage = FirebaseStorage.getInstance();
}

@Override
public void onMethodCall(MethodCall call, final Result result) {
if (call.method.equals("StorageReference#putFile")) {
Map<String, String> arguments = (Map<String, String>) call.arguments;
String filename = arguments.get("filename");
String path = arguments.get("path");
File file = new File(filename);
StorageReference ref = firebaseStorage.getReference().child(path);
UploadTask uploadTask = ref.putFile(Uri.fromFile(file));
uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot snapshot) {
result.success(snapshot.getDownloadUrl().toString());
}
});
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
result.error("upload_error", e.getMessage(), e.getStackTrace());
}
});
} else {
result.notImplemented();
}
}
}
10 changes: 10 additions & 0 deletions packages/firebase_storage/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.atom/
.idea
.packages
.pub/
build/
ios/.generated/
packages
pubspec.lock
.flutter-plugins
8 changes: 8 additions & 0 deletions packages/firebase_storage/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# firebase_storage_example

Demonstrates how to use the firebase_storage plugin.

## Getting Started

For help getting started with Flutter, view our online
[documentation](http://flutter.io/).
12 changes: 12 additions & 0 deletions packages/firebase_storage/example/android.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/android">
<sourceFolder url="file://$MODULE_DIR$/android/app/src/main/java" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
</component>
</module>
13 changes: 13 additions & 0 deletions packages/firebase_storage/example/android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
GeneratedPluginRegistrant.java

/gradle
/gradlew
/gradlew.bat
49 changes: 49 additions & 0 deletions packages/firebase_storage/example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'

lintOptions {
disable 'InvalidPackage'
}

defaultConfig {
applicationId 'io.flutter.plugins.firebase_storage_example'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}

flutter {
source '../..'
}

dependencies {
androidTestCompile 'com.android.support:support-annotations:25.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}

apply plugin: 'com.google.gms.google-services'
93 changes: 93 additions & 0 deletions packages/firebase_storage/example/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"project_info": {
"project_number": "297855924061",
"firebase_url": "https://flutterfire-cd2f7.firebaseio.com",
"project_id": "flutterfire-cd2f7",
"storage_bucket": "flutterfire-cd2f7.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:297855924061:android:669871c998cc21bd",
"android_client_info": {
"package_name": "com.yourcompany.firebaseauth.example"
}
},
"oauth_client": [
{
"client_id": "297855924061-col4in4uubarifm60nbq8id01ec3ss4c.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.yourcompany.firebaseauth.example",
"certificate_hash": "8a4e194f5bfc3fb1075e7daae8dcddd526fde207"
}
},
{
"client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyD_shO5mfO9lhy2TVWhfo1VUmARKlG4suk"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "297855924061-48k2m6hl6pa4q9hukijjd0c20ev4qans.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.yourcompany.firebaseAuthExample"
}
},
{
"client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:297855924061:android:92efa9a0df6f077f",
"android_client_info": {
"package_name": "io.flutter.plugins.firebase_storage_example"
}
},
"oauth_client": [
{
"client_id": "297855924061-f68m5v860ms5faiotn5mv9f50cmpacdq.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyD_shO5mfO9lhy2TVWhfo1VUmARKlG4suk"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
Loading