Re: Zogi Support for File Upload
Adam Tauno Williams <[email protected]> Tue, 04 Sep 2012 13:41:30 -0400
| Newsgroups | gmane.comp.cms.opengroupware.xmlrpc.devel |
|---|---|
| Message-ID | <[email protected]> |
--=-hK1Dy7xGTGWg+J3FFUU6
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
On Tue, 2012-09-04 at 12:33 -0400, Bill Creswell wrote:=20
> There is a function in the traditional OpenGroupware Client for uploading=
=20
> files.
> Is there a way to upload files (say to attach to a project) in the zogi =
=20
> implementation?
Not through zOGI / XML-RPC. Primarily because moving large amounts of
data over XML-RPC is inefficient. Binary data in XML-RPC is base64
encoded, so that itself is a ~20% bloat factor, and then the request is
de-serialized in memory [XML DOM] so the footprint would be at least
((size)+(size*1.2)). Given that an upload could easily be
50...200MB ... that gets ugly.
For either Zidestore [OpenGroupware Objective-C] or Coils [OpenGroupware
Python] files can be created in projects via HTTP PUT [WebDAV, aka
the-correct-way-to-do-REST]. But if you are using Coils by far the
simplest and most efficient way would be to use the AttachFS protocol.
=46rom WMOGAG-Coils:
------------------
Files can be created, updated, and renamed78 via PUT operations targeted
at the AttachFS presentation protocol. In order to use the AttachFS
protocol to operate on files rather than attachments the "mod"=E2=80=9D URL
parameter must be specified with a value of "file". If the file mode is
specified the {objectId} value of the target URL must be the object id
of either a folder or a file entity.
If the target object id indicates a folder then the folder is scanned
for a document whose full file-name [including extension] matches the
value of the {name} portion of the URL. If a file matching that name is
found then the contents of the file are replaced with the payload of the
PUT operation. If no matching file is found a new file is created in the
folder with the specified name.
If the target object id indicates a file then the contents of the
document are replaced with the payload of the PUT operation and the name
is updated to that of the {name} portion of the URL.
If the target object id matches neither a Folder or a File entity and
the "file" mode was specified an exception will be raised. Normal
security restrictions apply to the availability of the folders and files
within the authenticated user's security context.
curl -u adam -T snapper.log -H 'Content-Type: text/plain' \=20
http://coils.example.com/attachfs/30330610/george.txt?mode=3Dfile
Text 28: Example upload of file content via AttachFS. In this example
the contents of the file "snapper.log" will be uploaded to server; if
the object id 30330610 identities a folder entity the file named=20
"george.txt" in that folder will either be updated or created. If=20
object id 30330610 identifies a file that file will be updated and=20
potentially renamed to "george.txt".
Updating or creating a document via AttachFS will also set the
contentType and isTransient object properties of the document.
contentType will be changed to the MIME type specified by the
"Content-Type" header of the PUT operation and isTransient will be set
to a value of =E2=80=9CNO=E2=80=9D.
When a file is created via AttachFS no ACL values can be specified. If
ACLs are desired they can be applied to the document via a call to the
zOGI API's putObject method (pg. 74) after the file has been created. As
the file is created with no ACLs the ACLs of the Project containing the
document will be automatically copied to the new file if ACL inheritance
is enabled on the Project (pg. 66).
When a file is created or updated via AttachFS it is often useful to
acquire the object id of the file either for linking purposes or making
subsequent zOGI API calls to tweak the meta-data associated with the
file. To facilitate this the object id of the document is provided in
the HTTP response header X-OpenGroupware-Document-Id. The object id of
the folder containing the document is also provided in the HTTP response
header X-OpenGroupware-Folder-Id.
--=-hK1Dy7xGTGWg+J3FFUU6
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
iEYEABECAAYFAlBGPUoACgkQLRePpNle04NpSwCeJ10kTi8qyJa6M4aM2Y/m79Am
SxkAn3FvH/9AVYrJCDP11p2OlFL2BhPr
=yNiX
-----END PGP SIGNATURE-----
--=-hK1Dy7xGTGWg+J3FFUU6--
--
OpenGroupware.org XML-RPC
[email protected]
http://mail.opengroupware.org/mailman/listinfo/xmlrpc