sonergia/alfresco-laravel

此包已被废弃,不再维护。未建议替代包。

Alfresco在Laravel中的集成

1.0.6 2023-05-03 13:34 UTC

README

Alfresco-Laravel

Alfresco-Laravel是一个允许通过Laravel管理Alfresco中文件的包。

安装

composer require sonergia/alfresco-laravel:"^1.0"

服务提供者

安装完成后,您需要在您的config/app.php文件中注册Alfresco-Laravel,找到providers数组并添加以下内容

Sonergia\AlfrescoLaravel\AlfrescoLaravelServiceProvider::class,

别名

为了更简单地使用此包,您需要在config/app.php文件中的alias数组中注册别名,添加以下内容

'Alfresco' => Sonergia\AlfrescoLaravel\Models\AlfrescoLaravel::class

配置

最后,您必须发布配置文件以设置连接数据。

php artisan vendor:publish --tag=alfresco

这将把配置文件复制到config/alfresco.php

使用

配置完成后,该包即可使用。

上传

要将文件上传到Alfresco,您需要将以下行添加到您的代码中

use Alfresco; // At the top of your controller
------
Alfresco::upload($file); //When you want to upload a file, being $file a UploadedFile instance

此函数将返回一个布尔值,表示操作的结果。

列出文件夹内容

要列出Alfresco中文件夹的内容,您需要将以下行添加到您的代码中

use Alfresco; // At the top of your controller
------
Alfresco::list($nodeId); //When you want to list the content of a folder, being $nodeId the id of the folder to list

此函数的返回值将类似于以下内容

[
	"back" => "b4cff62a-664d-4d45-9302-98723eac1319", //The id of the parent folder (optional)
	"children" => [ //Array with all the childs of the folder (optional)
					[
						"id":"b31cfcd4-06a8-4a8e-8073-2b047aa2f82a", //The id of the child
						"name":"image1.png", //The name of the document/folder
						"isFolder":false //Boolean to indicate if the node is a folder or not
					],
					[
						"id":"a6b424ec-48b5-47b0-b42a-73785ed3d487",
						"name":"image2.jpg",
						"isFolder":false
					],
					[
						"id":"f2cb8696-a9a3-49d8-bd16-5960cb0c2948",
						"name":"document.pdf",
						"isFolder":false
					],
					[
						"id":"f1ba047c-d9b1-4554-aa56-7004f7327cf5",
						"name":"test",
						"isFolder":true
					]
				]
]

下载

要从Alfresco下载文件,您需要将以下行添加到您的代码中

use Alfresco; // At the top of your controller
------
Alfresco::download($nodeId, $destinationFolder); //When you want to download a file, being $nodeId the id of the node to download and $destinationFolder the route to the folder where de node will be storaged

此函数将返回一个布尔值,表示操作的结果。