Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 通过Silverstripe 4 RestulServer模块上载文件_Php_Silverstripe_Silverstripe 4 - Fatal编程技术网

Php 通过Silverstripe 4 RestulServer模块上载文件

Php 通过Silverstripe 4 RestulServer模块上载文件,php,silverstripe,silverstripe-4,Php,Silverstripe,Silverstripe 4,我的应用程序使用silverstripe来管理大量文件,以便下载/访问这些文件和一些关系元数据 一个要求是文件可以通过API从外部访问。我已经设置了Restfulserver模块()来实现这一点 并扩展了文件模型以允许restful访问: class FileExtension extends DataExtension { ... private static $api_access = true; ... } 这使我可以使用get获取和下载文件,而不会出现任何问

我的应用程序使用silverstripe来管理大量文件,以便下载/访问这些文件和一些关系元数据

一个要求是文件可以通过API从外部访问。我已经设置了Restfulserver模块()来实现这一点

并扩展了文件模型以允许restful访问:

class FileExtension extends DataExtension
{
    ...

    private static $api_access = true;

    ...
}
这使我可以使用get获取和下载文件,而不会出现任何问题:

silverstripe/public/api/v1/Silverstripe-Assets-File/(ID)
这给了我必要的数据来点击资产/{hash}/(文件名)并下载文件

但它似乎没有给我发布文件的方法。在此处过帐只会创建文件记录,但资产文件夹中没有附带文件。手动删除文件夹中的文件无效,因为该文件未被记录引用,并且没有关联的哈希


那么如何在没有页面控制器的情况下上传文件呢?

我不知道
restfulserver
模块是否支持开箱即用的文件上传。我认为您需要为此创建自定义控制器操作。您可以将默认的POST文件端点设置为控制器操作的路由。这样可以保持端点URI的一致性。