React Native OMH Storage - OneDrive
Prerequisites
Before starting the integration, make sure the following packages are installed and configured:
@openmobilehub/storage-core
react-native-file-access
@react-native-async-storage/async-storage
react-native-app-auth
- Configuration@openmobilehub/auth-core
- Configuration@openmobilehub/auth-microsoft
- Configuration
Installation
npm add @openmobilehub/storage-onedrive
Console App
To access OneDrive APIs, follow these steps to obtain the MSAL Configuration:
- Create a new app in Microsoft Azure.
- Add the Android platform and specify your Package Name and Signature Hash for your app.
- Copy the MSAL Configuration into a newly created JSON file named ms_auth_config.json and place it in the android/app/src/main/res/raw directory.
- In the ms_auth_config.json file, add a new key
"account_mode"
with the value"SINGLE"
.
Secrets
To securely configure the OneDrive storage provider, add the following entry to your project's local.properties file:
MICROSOFT_SIGNATURE_HASH=<YOUR_MICROSOFT_SIGNATURE_HASH>
Usage
Initializing
To interact with the OneDrive storage provider, start by initializing the OMH Auth Client. Once the authentication client is set up, you can then initialize the OMH Storage Client.
import MicrosoftAuth from '@openmobilehub/auth-microsoft';
import { OneDriveStorageClient } from '@openmobilehub/storage-onedrive';
const scopes = ['User.Read', 'Files.ReadWrite.All'];
await MicrosoftAuth.initialize({
android: {
scopes,
configFileName: 'ms_auth_config',
},
ios: {
scopes,
clientId: '<YOUR_MICROSOFT_CLIENT_ID>',
redirectUrl: 'msauth.<YOUR_PACKAGE_NAME>://auth/',
},
});
const oneDriveStorageClient = new OneDriveStorageClient(MicrosoftAuth);
Other methods
Interacting with the OneDrive storage provider follows the same pattern as other storage providers since they all implement the IStorageClient
interface. This uniformity ensures consistent functionality across different storage providers, so you won’t need to learn new methods regardless of the storage provider you choose! For a comprehensive list of available methods, refer to the Getting Started guide.
When updating a file, if the new file has a different name than the updated file, two additional versions might sometimes appear in the system. One version comes from updating the content of the file, and the other comes from updating the file name.
When updating a file created by the createFileWithExtension method, no new version appears immediately after the first update. However, once the file has been updated, subsequent updates will generate new versions.
The Sharing Links permissions are not supported.
The search query takes several fields including filename, metadata, and file content when searching.
License
- See LICENSE