@@ -28,39 +28,26 @@ void RNFetchBlob::Initialize(winrt::Microsoft::ReactNative::ReactContext const&
28
28
//
29
29
void RNFetchBlob::ConstantsViaConstantsProvider (winrt::Microsoft::ReactNative::ReactConstantProvider& constants) noexcept
30
30
{
31
- // RNFS.MainBundlePath
32
- // constants.Add(L"RNFSMainBundlePath", to_string(Package::Current().InstalledLocation().Path()));
33
-
34
- // RNFS.CachesDirectoryPath
35
- // constants.Add(L"RNFSCachesDirectoryPath", to_string(ApplicationData::Current().LocalCacheFolder().Path()));
36
-
37
- // RNFS.ExternalCachesDirectoryPath - NULL in iOS (No equivalent in Windows)
38
-
39
- // RNFS.DocumentDirectoryPath
40
- // constants.Add(L"RNFSDocumentDirectoryPath", to_string(ApplicationData::Current().LocalFolder().Path()));
41
-
42
- // RNFS.DownloadDirectoryPath - IMPLEMENT for convenience? (absent in iOS and deprecated in Android)
43
- // constants.Add(L"RNFSDownloadDirectoryPath", UserDataPaths::GetDefault().Downloads());
44
-
45
- // RNFS.ExternalDirectoryPath - NULL in iOS (Pending use case in Windows and deprecated in Android)
46
- // constants.Add(L"RNFSExternalDirectoryPath", UserDataPaths::GetDefault().Documents());
47
-
48
- // RNFS.ExternalStorageDirectoryPath - NULL in iOS (Pending use case in Windows and deprecated in Android)
49
-
50
- // RNFS.TemporaryDirectoryPath
51
- // constants.Add(L"RNFSTemporaryDirectoryPath", to_string(ApplicationData::Current().TemporaryFolder().Path()));
52
-
53
- // RNFS.LibraryDirectoryPath - NULL in Android (No equivalent in Windows)
54
-
55
- // RNFS.PicturesDirectoryPath - IMPLEMENT for convenience? (absent in iOS though and deprecated in Android)
56
- // constants.Add(L"RNFSPicturesDirectoryPath", UserDataPaths::GetDefault().Pictures());
57
-
58
- // RNFS.FileProtectionKeys - NULL in Android (No equivalent in Windows)
59
-
60
- // TODO: Check to see if these can be accessed after package created
61
- // Needed for synchronization across Windows devices
62
- // /constants.Add(L"RNFSRoamingDirectoryPath", to_string(ApplicationData::Current().RoamingFolder().Path()));
63
-
31
+ // RNFetchBlob.DocumentDir
32
+ constants.Add (L" DocumentDir" , to_string (ApplicationData::Current ().LocalFolder ().Path ()));
33
+
34
+ // RNFetchBlob.CacheDir
35
+ constants.Add (L" CacheDir" , to_string (ApplicationData::Current ().LocalCacheFolder ().Path ()));
36
+
37
+ // RNFetchBlob.PictureDir
38
+ constants.Add (L" PictureDir" , UserDataPaths::GetDefault ().Pictures ());
39
+
40
+ // RNFetchBlob.MusicDir
41
+ constants.Add (L" MusicDir" , UserDataPaths::GetDefault ().Music ());
42
+
43
+ // RNFetchBlob.MovieDir
44
+ constants.Add (L" MusicDir" , UserDataPaths::GetDefault ().Videos ());
45
+
46
+ // RNFetchBlob.DownloadDirectoryPath - IMPLEMENT for convenience? (absent in iOS and deprecated in Android)
47
+ constants.Add (L" DownloadDir" , UserDataPaths::GetDefault ().Downloads ());
48
+
49
+ // RNFetchBlob.MainBundleDir
50
+ constants.Add (L" MainBundleDir" , to_string (Package::Current ().InstalledLocation ().Path ()));
64
51
}
65
52
66
53
// createFile
@@ -417,23 +404,28 @@ try
417
404
}
418
405
if (usedEncoding == EncodingOptions::BASE64)
419
406
{
420
- std::wstring base64Content{ Cryptography::CryptographicBuffer::EncodeToBase64String (readBuffer) };
407
+ // TODO: Investigate returning wstrings as parameters
408
+ // std::wstring base64Content{ Cryptography::CryptographicBuffer::EncodeToBase64String(readBuffer) };
409
+ std::string base64Content{ winrt::to_string (Cryptography::CryptographicBuffer::EncodeToBase64String (readBuffer)) };
421
410
m_reactContext.CallJSFunction (L" RCTDeviceEventEmitter" , L" emit" , streamId,
422
411
winrt::Microsoft::ReactNative::JSValueObject{
423
- {" data" , base64Content},
412
+ {" data" , " base64Content" },
424
413
});
425
414
}
426
415
else
427
416
{
428
- std::wstring utf8Content{ Cryptography::CryptographicBuffer::ConvertBinaryToString (BinaryStringEncoding::Utf8, readBuffer) };
417
+ // TODO: Investigate returning wstrings as parameters
418
+ std::string utf8Content{ winrt::to_string (Cryptography::CryptographicBuffer::ConvertBinaryToString (BinaryStringEncoding::Utf8, readBuffer)) };
429
419
if (usedEncoding == EncodingOptions::ASCII)
430
420
{
431
- std::string asciiContent{ winrt::to_string (utf8Content) };
432
- std::wstring asciiResult{ winrt::to_hstring (asciiContent) };
421
+
422
+ // std::string asciiContent{ winrt::to_string(utf8Content) };
423
+ std::string asciiContent{ utf8Content };
424
+ // std::wstring asciiResult{ winrt::to_hstring(asciiContent) };
433
425
// emit ascii content
434
426
m_reactContext.CallJSFunction (L" RCTDeviceEventEmitter" , L" emit" , streamId,
435
427
winrt::Microsoft::ReactNative::JSValueObject{
436
- {" data" , asciiResult },
428
+ {" data" , asciiContent },
437
429
});
438
430
}
439
431
else
@@ -456,7 +448,7 @@ catch (const hresult_error& ex)
456
448
{
457
449
m_reactContext.CallJSFunction (L" RCTDeviceEventEmitter" , L" emit" , L" DownloadBegin" ,
458
450
winrt::Microsoft::ReactNative::JSValueObject{
459
- {streamId, L" help " },
451
+ {streamId, winrt::to_string (ex. message ()). c_str () },
460
452
});
461
453
}
462
454
0 commit comments