简体   繁体   English

REST中的资源多编辑

[英]Multi edit of resources in REST

I want to edit multiple resources over REST. 我想通过REST编辑多个资源。 For example I have folders and files. 例如,我有文件夹和文件。

Now I move three files from folder A to folder B. For edit the parentId of the file I use the PATCH action. 现在,我将三个文件从文件夹A移到文件夹B。为编辑文件的parentId,我使用了PATCH操作。

When I want to keep the controller RESTful do i need to send for each moved file a request to my REST controller? 当我想保持控制器为RESTful时,是否需要为每个移动文件发送一个请求给我的REST控制器?

I think you should add a transaction resource. 我认为您应该添加交易资源。

POST /transactions
{
    type: "move",
    files: [...],
    destinies: [...],
}

202 - accepted
{
    progress: 0.23,
    _links: {
        self: {href: "/transactions/123"}
    }
}

It could be just temporary, or you could use the collection as an event log. 它可能只是临时的,或者您可以将集合用作事件日志。 By getting the representation of it with comet or websocket could contain the progress... 通过使用Comet或websocket获得它的表示,可以包含进度...

I don't think there are any other options, only moving the files one by one, or patching the directory of the files if they contain a property like that... 我认为没有其他选择,只能逐个移动文件,或者如果文件包含这样的属性,则修补文件的目录...

如果您的API支持通过在文件上执行PATCH来移动文件,那么可以,您将针对每个要移动的文件发送不同的请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM