Coder Social home page Coder Social logo

Implement File API about plone.restapi HOT 6 CLOSED

plone avatar plone commented on August 18, 2024
Implement File API

from plone.restapi.

Comments (6)

davisagli avatar davisagli commented on August 18, 2024

data/download as a URI or embedded base64 data? The former is probably better (fewer bytes to download)

from plone.restapi.

tisto avatar tisto commented on August 18, 2024

As URI. We might want to support embedded base64 data in future versions (maybe with framing).

from plone.restapi.

lukasgraf avatar lukasgraf commented on August 18, 2024

The current serialization for a File looks like this:

{
  "@id": "http://nohost/plone/document.pdf",
  "@type": "File",
  "title": "My PDF document",
  "UID": "abef59538b3749debad950c3c5d35224",
  "...": "...",
  "file": "http://nohost/plone/document.pdf/@@download/file"
}

So a Named[Blob]File field gets serialized directly to its regular Plone download URL (as currently documented in the Serialization chapter).

I would propose to change the serialization to something that is slightly more in line with the format used for deserialization (upload):

{
  "@id": "http://nohost/plone/document.pdf",
  "...": "...",
  "file": {
    "filename": "document.pdf",
    "content-type": "application/pdf",
    "size": 65536,
    "download": "http://nohost/plone/document.pdf/@@download/file"
  }
}

That way, clients would have the necessary information to render a decent download link, including icon, filename and size without doing a second request.

The contract would then be that the client can do a GET request to the URL specified in download, with the same credentials, and will get back a response with appropriate Content-Disposition, Content-Length, and Content-Type headers as indicated in the metadata.

The same principle could probably be applied to images scales.

/cc @tisto @buchi

from plone.restapi.

tisto avatar tisto commented on August 18, 2024

@lukasgraf you proposal looks good to me. It is essential that serialization/deserialization use the same structure. I guess from a HTTP spec perspective it would be correct if the client would send a GET request to "http://localhost:8080/Plone/document.pdf/@@download/file" with Accept "application/pdf" header. Though, since it works without the Accept header in Plone as well I guess we don't have to be pedantic about it.

from plone.restapi.

lukasgraf avatar lukasgraf commented on August 18, 2024

@tisto I agree, this would be the proper behavior. But since Accept: */* or no Accept header at all would also happen to work, we might just phrase this as a recommendation to the client / description of how the server is expected to behave in the docs.

I'll start working on this (and Images) then, PR coming up.

from plone.restapi.

tisto avatar tisto commented on August 18, 2024

Closed by #115

from plone.restapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.