承接 jasonbdaro/laravel-sharepoint-upload-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jasonbdaro/laravel-sharepoint-upload-client

Composer 安装命令:

composer require jasonbdaro/laravel-sharepoint-upload-client

包简介

Simple library for file uploading to Microsoft Sharepoint site

README 文档

README

Simple Client for uploading files to Sharepoint Online library. Integrated Laravel Service Provider.

Uses accesscontrol.windows.net OAuth2, so it works with MS ADFS or Azure AAD Authentication.

Usage:

Register ServiceProvider in your app.php:

\JakubKlapka\LaravelSharepointUploadClient\LaravelSharepointUploadProvider::class

Use Client factory to make Client instance:

class Controller {

	protected $sharepointClient;

	public function __construct( \JakubKlapka\LaravelSharepointUploadClient\Factories\ClientFactory $sharepointClient ) {
		$this->sharepointClient = $sharepointClient;
	}
	
	public function upload() {
		$client = $this->sharepointClient->makeClient( $site_url, $app_id, $app_secret, $redirect_uri );
	}

}

You will need those attributes, you can register Sharepoint App on: https://contoso.sharepoint.com/sites/MySite/_layouts/15/appregnew.aspx

Attribute Description Example
site_url Abosolute path to root of your sharepoint site https://contoso.sharepoint.com/sites/MySite
app_id ID of your app
app_secret Secret of your app
redirect_uri Redirect URI has to match the one, entered on appregnew.aspx https://myapp.com/shp-oauth/

Point you user to retrieve Consent:

$url = $client->getUserConsentUri()

Get refresh token from auth code, returned based on Consent:

$auth_code = $_REQUEST['code'];
$refreshToken = $client->getRefreshTokenFromAuthCode( $auth_code );

This client does not handle token persistence, feel free to save it to file/db/redis or wherever it is fit for your app.

Refresh token is valid for 6 months.

Use refresh token to upload a file

$upload_result = $client->uploadFile(
	$refresh_token,
	'/sites/mySite/myLibrary/',
	'file.txt',
	$this->transfer_storage->readStream( 'file.txt' )
);

Resources

统计信息

  • 总下载量: 1.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-29