No release in over 3 years
Integration gem for Rails Active Storage to use Microsoft 365 (SharePoint) as a storage backend. Provides seamless OAuth2 authentication and Microsoft Graph API integration for file management.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

m365-active-storage

Rails ActiveStorage in M365 Sharepoint

Install the gem

gem install m365_active_storage

or add to the Gemfile:

gem "m365_active_storage"

Configure ActiveStorage

Configure Active Storage and auth

Rails credentials

sharepoint:
  ms_graph_url:
  ms_graph_version:
  auth_host:
  oauth_tenant:
  oauth_app_id:
  oauth_secret:
  sharepoint_site_id:
  sharepoint_drive_id:

-- or --

ENV

MS_GRAPH_URL=
MS_GRAPH_VERSION=
AUTH_HOST=
OAUTH_TENANT=
OAUTH_APP_ID=
OAUTH_SECRET=
SHAREPOINT_SITE_ID=
SHAREPOINT_DRIVE_ID=

Set active storage to sharepoint service

In the app config/environments/<environment>.rb

  config.active_storage.service = :sharepoint

Run the check generator

$ rails g m365_active_storage:check

Move files from local to sharepoint with the migrate generator

g m365_active_storage:migrate
5 blobs to migrate
filename_1 done
filename_2 done
filename_3 done
filename_4 failed: ActiveStorage::FileNotFoundError
filename_5 done
...

Note

The local files are still in the storage folder.

You must delete them manually after validating the data has been correctly moved.

Note

Don't forget to restart your server, if running