Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3004212
D13040.id43292.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13040.id43292.diff
View Options
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -1229,17 +1229,29 @@
path = resolvedPath;
}
}
+
+ let uploadOptions = {
+ uploadType: FileSystem.FileSystemUploadType.MULTIPART,
+ fieldName: 'multimedia',
+ headers: {
+ Accept: 'application/json',
+ },
+ parameters,
+ };
+ if (Platform.OS === 'android' && path.endsWith('.dat')) {
+ // expo-file-system is not able to deduce the MIME type of .dat files, so
+ // we specify it explicitly here. Without this, we get this error:
+ // guessContentTypeFromName(file.name) must not be null
+ uploadOptions = {
+ ...uploadOptions,
+ mimeType: 'application/octet-stream',
+ };
+ }
+
const uploadTask = FileSystem.createUploadTask(
url,
path,
- {
- uploadType: FileSystem.FileSystemUploadType.MULTIPART,
- fieldName: 'multimedia',
- headers: {
- Accept: 'application/json',
- },
- parameters,
- },
+ uploadOptions,
uploadProgress => {
if (options && options.onProgress) {
const { totalByteSent, totalBytesExpectedToSend } = uploadProgress;
diff --git a/native/utils/blob-service-upload.js b/native/utils/blob-service-upload.js
--- a/native/utils/blob-service-upload.js
+++ b/native/utils/blob-service-upload.js
@@ -18,6 +18,7 @@
if (input.blobInput.type !== 'uri') {
throw new Error('Wrong blob data type');
}
+
let path = input.blobInput.uri;
if (Platform.OS === 'android') {
const resolvedPath = pathFromURI(path);
@@ -25,17 +26,29 @@
path = resolvedPath;
}
}
+
const headers = authMetadata && createDefaultHTTPRequestHeaders(authMetadata);
+ let uploadOptions = {
+ uploadType: FileSystem.FileSystemUploadType.MULTIPART,
+ fieldName: 'blob_data',
+ httpMethod: method,
+ parameters: { blob_hash: input.blobHash },
+ headers,
+ };
+ if (Platform.OS === 'android' && path.endsWith('.dat')) {
+ // expo-file-system is not able to deduce the MIME type of .dat files, so we
+ // specify it explicitly here. Without this, we get this error:
+ // guessContentTypeFromName(file.name) must not be null
+ uploadOptions = {
+ ...uploadOptions,
+ mimeType: 'application/octet-stream',
+ };
+ }
+
const uploadTask = FileSystem.createUploadTask(
url,
path,
- {
- uploadType: FileSystem.FileSystemUploadType.MULTIPART,
- fieldName: 'blob_data',
- httpMethod: method,
- parameters: { blob_hash: input.blobHash },
- headers,
- },
+ uploadOptions,
uploadProgress => {
if (options?.onProgress) {
const { totalByteSent, totalBytesExpectedToSend } = uploadProgress;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 19, 1:28 PM (22 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2323119
Default Alt Text
D13040.id43292.diff (2 KB)
Attached To
Mode
D13040: [native] Fix encrypted media upload on Android
Attached
Detach File
Event Timeline
Log In to Comment