GatherContent has deprecated the use of "url" within https://docs.gathercontent.com/reference#get-item-files - The correct method of downloading the file is to now call https://docs.gathercontent.com/reference#get-filesfile_iddownload which is authenticated, where as before it wasn't so a standard file_get_contents would suffice.

Downloading files
Although the list files endpoint returns a file URL in the response, this should not be used to download the file content, and should be considered deprecated to be removed in the next API version. The correct way to download the file content is to make an authenticated GET request to /files/{file_id}/download. See docs further down https://docs.gathercontent.com/reference#get-filesfile_iddownload

I contacted GatherContent as they hadn't incremented their API version from 0.5 at all so the depreciation seemed out of the blue. I've provided a patch for 7.x-3.3 which is tested and confirmed works, the implementation isn't the nicest and may cause memory issues if dealing with lots of files but a bit of rewrite would of been required otherwise.

Also attached a patch for the latest dev build on 7.x-3.x-dev but this is untested (due to conflicts on guzzlehttp versions within composer manager), can someone please verify.

I've done a brief check into the latest dev alpha build on D8 and believe the same the same issue exists.

Comments

trothwell created an issue. See original summary.

Kova101’s picture

StatusFileSize
new2.99 KB

Hello trothwell,

Thank you for the patch!
I reviewed it and made another one for the 7.x-3.x branch.
Your solution worked perfectly only one thing was not right.
In your implementation the backend logic would download all the files for an entity which can cause some unused files.
I changed the implementation to download only the required files and left the others out from the pool.

You can find the patch attached. the 7.x-3.3 will come soon, but my advice is that to use the latest version of the module (just for information, the 7.x-3.5 has a security fix, so it is highly recommended to use that version).

And as you mentioned, the 8.x versions had this bug also, but I already fixed that in the 8.x-4.x and 8.x-3.x branches.
I will soon make a release for these.

  • Kova101 committed 5c3a63f on 7.x-3.x authored by trothwell
    Issue #3059496 by trothwell, Kova101: File downloads no longer work
    
Kova101’s picture

StatusFileSize
new2.92 KB

And here comes the 3.3 patch!
It contains the same logic, so please trothwell confirm that it works for you as well.

  • Kova101 committed 59b7272 on 7.x-3.x authored by trothwell
    Issue #3059496 by trothwell, Kova101: File downloads no longer work
    
Kova101’s picture

StatusFileSize
new1.09 KB
new2.97 KB
new2.91 KB

Oops I left an undefined variable in the code sorry, here are the fixes.
So please ignore my previous patches.

  • Kova101 committed 0fb0d81 on 7.x-3.x
    Issue #3059496 by Kova101, trothwell: File downloads no longer work
    
trothwell’s picture

Perfect, thanks for the prompt reply. Looks good! The upgrade is on the todo list in the coming days.

Thanks again.

Kova101’s picture

StatusFileSize
new2.9 KB
new2.96 KB

Sorry again..... This is not my day...
I promise these are the last ones.

trothwell’s picture

Might be a bit too early? :P

https://i.imgur.com/r8OXhw0.png

Kova101’s picture

Or too late, depends :D

Csongi95’s picture

Status: Needs review » Fixed

I checked and tested it.

This issue is fixed and pushed in the new release (7.x-3.6).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.