From 2129f32db6320d3c41f100b14c46b42ed821d384 Mon Sep 17 00:00:00 2001 From: nico1510 Date: Thu, 29 Jun 2017 19:32:40 +0200 Subject: [PATCH] fixed customMetadata android --- .../firebase/storage/RNFirebaseStorage.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java index 4e2abbf3..9e68124c 100644 --- a/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java +++ b/android/src/main/java/io/invertase/firebase/storage/RNFirebaseStorage.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.HashMap; @@ -428,10 +429,26 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule { */ private StorageMetadata buildMetadataFromMap(ReadableMap metadata) { StorageMetadata.Builder metadataBuilder = new StorageMetadata.Builder(); - Map m = Utils.recursivelyDeconstructReadableMap(metadata); - for (Map.Entry entry : m.entrySet()) { - metadataBuilder.setCustomMetadata(entry.getKey(), entry.getValue().toString()); + try { + + Map m = Utils.recursivelyDeconstructReadableMap(metadata); + + Map customMetadata = (Map) m.get("customMetadata"); + if (customMetadata != null) { + for (Map.Entry entry : customMetadata.entrySet()) { + metadataBuilder.setCustomMetadata(entry.getKey(), String.valueOf(entry.getValue())); + } + } + + metadataBuilder.setCacheControl((String) m.get("cacheControl")); + metadataBuilder.setContentDisposition((String) m.get("contentDisposition")); + metadataBuilder.setContentEncoding((String) m.get("contentEncoding")); + metadataBuilder.setContentLanguage((String) m.get("contentLanguage")); + metadataBuilder.setContentType((String) m.get("contentType")); + + } catch (Exception e) { + Log.e(TAG, "error while building meta data " + e.getMessage()); } return metadataBuilder.build();