Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create JSON files #1011

Closed
boulderwebdev opened this issue Dec 6, 2018 · 10 comments

Comments

8 participants
@boulderwebdev
Copy link

commented Dec 6, 2018

If I try to POST or PUT a JSON file using solid.auth.fetch then an empty file is stored on the server. For example, I could call

const data = JSON.stringify({
  "hello": "world"
})
const url = 'https://boulderwebdev.solid.community/public/'
solid.auth.fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Slug": "data",
    "Content-Length": data.length
  },
  body: data
}).then((resp) => {  ... })

and the server will create a file and respond with

201
allow OPTIONS, HEAD, GET, PATCH, POST, PUT, DELETE
content-length 7
content-type text/plain; charset=utf-8
etag W/"7-rM9AyJuqT6iOan/xHh+AW+7K/T8"
link <.acl>; rel="acl", <.meta>; rel="describedBy", <http://www.w3.org/ns/ldp#Container>; rel="type", <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"
location /public/data.json
vary Accept, Authorization, Origin

@kjetilk kjetilk added the triage label Dec 6, 2018

@kjetilk

This comment has been minimized.

Copy link
Contributor

commented Dec 10, 2018

@RubenVerborgh Do you think this might be a solid-auth-client issue?

@RubenVerborgh

This comment has been minimized.

Copy link
Member

commented Dec 10, 2018

I'm suspicious of:

  • slug being equal to data, since it results in an invalid slug (and NSS probably doesn't check)
  • Content-Length being set in what I presume is the browser (don't do that, the browser does it for you)
@boulderwebdev

This comment has been minimized.

Copy link
Author

commented Dec 10, 2018

@RubenVerborgh I was using the slug data as just example data. In my case I am using either a uuid or a file named config. I removed the Content-Length header too, but that didn't change anything.

@RubenVerborgh

This comment has been minimized.

Copy link
Member

commented Dec 10, 2018

Okay, thanks. The client still wouldn't be my first suspect, because it doesn't touch any of the relevant headers, nor body.

@boulderwebdev

This comment has been minimized.

Copy link
Author

commented Dec 11, 2018

@RubenVerborgh Also, if you set the content type to the invalid value "text/json", the server saves the JSON file correctly...

@RubenVerborgh

This comment has been minimized.

Copy link
Member

commented Dec 11, 2018

Just to be sure

then an empty file is stored on the server.

So you get the 201, which is empty (that is expected).
But when you perform another GET on the resource, do you receive 200 or 404?

@bourgeoa

This comment has been minimized.

Copy link

commented Dec 20, 2018

I have the same issue trying to add a file.json with the UI green + button. The file is created with zero length. I can create/edit the content with the Solid-ide-file app.
By the way file.js are accepted but the extension is .js_false

@timbl

This comment has been minimized.

Copy link
Contributor

commented Dec 24, 2018

That is a separate issue with the data browser UI... when you create a new text file by clicking on the plus, it creates it with zero bytes,. That's normal. What is non-ideal is that it doesn't open the source pane to allow you to edit it. (or are you dragging a file onto the green plus?)

@bourgeoa

This comment has been minimized.

Copy link

commented Dec 24, 2018

I was dragging an existing file onto the green +

@megoth megoth added the priority-high label Feb 4, 2019

@michielbdejong michielbdejong added this to To do in ASAP on Server via automation Mar 25, 2019

jaxoncreed added a commit that referenced this issue Mar 29, 2019

Merge pull request #1158 from solid/fix/#1011
Fixed JSON not being written to file
@jaxoncreed

This comment has been minimized.

Copy link
Contributor

commented Apr 1, 2019

Fixed in #1158

@jaxoncreed jaxoncreed closed this Apr 1, 2019

ASAP on Server automation moved this from To do to Done Apr 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.