Description
(This is a more detailed proposal continuation of issue solid/solid#49.)
Motivation / Problem Statement
We need a bandwidth-efficient method to copy data to and from Solid pods.
Imagine you're building a 'Save to Solid' widget / app / browser extension. The idea is - the user is browsing some Web resource (a PDF file, or an image, or a video, etc), and would like to save it to their pod (to be able to tag it and do other sorts of CMS stuff on it).
Currently, the only way to perform this operation would be multi-step:
- GET resource and somehow store it temporarily in the client (in browser memory?)
- PUT the temp resource on the pod (upload it)
Putting aside the implementation details, this presents two problems: temporary storage space (if the file is being held in a Javascript variable in a web app, or in LocalStorage, this quickly presents challenges when the resource is large), and bandwidth.
This is especially problematic on resource-constrained clients (like mobile apps or browsers) -- the user first has to use their mobile data to download a file temporarily, and then use mobile data to upload that resource to their pod.
Proposed Solution 1: COPY
Method
Note: As @RubenVerborgh points out, we should separate the problem / use case from the proposed solution.
Add a new Solid-specific LDP method, COPY
, inspired by the existing WebDAV COPY method.
This proposed solution lets pods play to their strength, to act as always-connected high(er) bandwidth servers. Specifically, it allows a client to issue a single COPY command, and the server would perform the necessary data transfer (using its own bandwidth, not the client's).
This would be just a single step:
- issue a command to COPY resource from source URL to destination URL (server would proceed with the operation).
COPY Example
To copy FROM an external URL, https://example.com/example.pdf
, TO a user's POD, alice.inrupt.net
:
COPY /papers/example.pdf HTTP/1.1
Host: alice.inrupt.net
Source: https://example.com/example.pdf
HTTP/1.1 201 Created
Date: Mon, 23 May 2019 22:38:34 GMT
Content-Type: application/pdf
Location: https://alice.inrupt.net/papers/example.pdf
COPY
Method Specs
This method is idempotent, but not safe (see Section 9.1 of RFC2616). Responses to this method must not be cached.
Copying non-Container resources
(Note, this is what's currently implemented on node-solid-server
; copying of containers is not implemented.)
When the source resource is not a collection, the result of the COPY method is the creation of a new resource at the destination whose state and behavior match that of the source resource as closely as possible.
To copy a resource FROM an external URL TO a Solid pod:
COPY <destination url>
Source: <source url>
(Note that this is backwards from the current WebDAV semantics, which uses COPY <source url>, Destination: <destination url>
, see below.)
Copying Container resources
(Question: Should this be supported?)
See the WebDAV COPY for Collections spec for discussion of what's involved, including the handling of recursion via the Depth:
header.
Difference from WebDAV COPY
WebDAV's COPY is intended primarily for transfering data out of the WebDAV server and into an external destination. Its syntax is: COPY <source url>
with the Destination: <destination url>
header.
It does not, however, support the common use case where the source URL resides on an external server, and you want to copy it to yours. (In other words, it does not support the Source:
header.)
Since the motivation for Solid's COPY method is the latter (transfering from an external resource to a Solid pod), the Solid COPY method should support the Source:
header (in addition or instead of the Destination:
header).
ACL Interactions
Copying from a non-LDP public Web resource to a container:
A COPY operation requires that the authenticated user has Write access to the destination container.
Copying FROM an LDP container to an LDP container:
A COPY operation requires that the authenticated user has Read access on the source container, and Write access on the destination container.
Interfacing with actual WebDAV servers:
Out of scope for the moment. We just need this as a convenience method to move to and from Solid pods.
Design Questions
- This Solid/LDP Copy method uses a
Source:
request header, to handle the use case of transfering resources from an external source to a Solid pod. Question: Should the WebDAV styleDestination:
header operation be supported as well? (For transfering resources from a pod to another external pod). - Should COPY be supported on LDP Containers? (What about recursive copy?)
COPY Implementation Notes
- The proposed COPY method is currently implemented on
node-solid-server
, for experimental purposes. - The current implementation only supports the most common authentication use case (the external resource is public).
- Developers using this method should be aware of
.acl
files when copying resources (for example, if a file has its own.acl
, first copy the.acl
, and then the resource itself).
Proposed Solution 2: ?
?? (Discuss whether the use case can be solved using existing LDP methods).