Lullabot / copelandia

56 stars 18 forks source link

RestWS and file paths #10

Closed sirkitree closed 1 year ago

sirkitree commented 11 years ago

The file path that RestWS serves up for a node object is

field_recipe_photos: [
  0: {
    alt: "",
    file: {
      uri:"http://copelandia.lulladev.com/file/2", 
      id:"2", 
      resource:"file"
    }
  }
]

Obviously that is not the correct uri for the file. Need to figure out how to get the entire uri. Is this a bug in restws?

q0rban commented 11 years ago

Looks like it's trying to give you the path to another restws url, of the form file/[fid].

sirkitree commented 11 years ago

Ah, you're right. If you append.json to that (http://copelandia.lulladev.com/file/2.json) you get:

{
fid: "2",
name: "pokern.jpg",
mime: "image/jpeg",
size: "29333",
url: "http://copelandia.lulladev.com/sites/default/files/recipe_photos/pokern.jpg",
timestamp: "1363803325"
}

I'll use that. I'm slightly non-plussed to have to do another call though...

q0rban commented 11 years ago

I agree. It'd be nice if you received the object instead of a URL to an object, IMO. Is that possible with restws?

webthingee commented 11 years ago

I agree with @sirkitree seems like that data should be available with the same feed... is that possible...

sirkitree commented 11 years ago

I don't see any options for it, and https://github.com/Lullabot/copelandia/blob/master/docroot/sites/all/modules/contrib/restws/restws.entity.inc#L325 is where I think it's getting the info for fields. Might take some sort of modification there to make it happen?

sirkitree commented 11 years ago

I think this issue is related: http://drupal.org/node/1335958

sirkitree commented 11 years ago

In the above commit you'll see that I looped through and made a call for each image. Not ideal, but works for now.

webthingee commented 11 years ago

Looks like the images do not match to the titles, as you refresh you get different image for same title. I have some css that holds the placeholder open for easier viewing atm. Perhaps because titles get sorted?

sirkitree commented 11 years ago

I'm working on refactoring this to be more accurate and use factories

sirkitree commented 11 years ago

Refactoring complete. Images show up where they should. However, it's still a band-aide and not a fix. I still have to do some crazy workaround to do another call for each file, and even though I'm caching it to make it faster, it's still not something I should have to do.

sirkitree commented 11 years ago

That last d.o issue was not very specific and the op had a different problem that has since been resolves to i closed it and opened http://drupal.org/node/1978202