fixed customMetadata android

This commit is contained in:
nico1510 2017-06-29 19:32:40 +02:00
parent 0f11da0e0b
commit 2129f32db6
1 changed files with 20 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
@ -428,10 +429,26 @@ public class RNFirebaseStorage extends ReactContextBaseJavaModule {
*/ */
private StorageMetadata buildMetadataFromMap(ReadableMap metadata) { private StorageMetadata buildMetadataFromMap(ReadableMap metadata) {
StorageMetadata.Builder metadataBuilder = new StorageMetadata.Builder(); StorageMetadata.Builder metadataBuilder = new StorageMetadata.Builder();
Map<String, Object> m = Utils.recursivelyDeconstructReadableMap(metadata);
for (Map.Entry<String, Object> entry : m.entrySet()) { try {
metadataBuilder.setCustomMetadata(entry.getKey(), entry.getValue().toString());
Map<String, Object> m = Utils.recursivelyDeconstructReadableMap(metadata);
Map<String, Object> customMetadata = (Map<String, Object>) m.get("customMetadata");
if (customMetadata != null) {
for (Map.Entry<String, Object> 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(); return metadataBuilder.build();