Skip to content

Add fileid preview endpoint - #7902

Merged
MorrisJobke merged 2 commits into
masterfrom
fix_7700
Jan 24, 2018
Merged

MorrisJobke merged 2 commits into
masterfrom
fix_7700

Conversation

@rullzer

@rullzer rullzer commented Jan 16, 2018

Copy link
Copy Markdown
Member

Fixes #7700

File paths can change. The fileid is stable.

To observer watch your network console:

  1. Upload an image
  2. Open sidebar for that image
  3. Now rename the file
  4. Observe no new network request but the preview is still there

🎈

@rullzer

rullzer commented Jan 17, 2018

Copy link
Copy Markdown
Member Author

@MorrisJobke this is what you had in mind right?

Comment thread core/routes.php Outdated
['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'],
['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'],
['name' => 'Preview#getPreviewByPath', 'url' => '/core/preview.png', 'verb' => 'GET'],
['name' => 'Preview#getPreviewByFileId', 'url' => '/core/preview.fileid', 'verb' => 'GET'],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/core/preview.fileid.png for our friend IE11? 😉 (not tested but just a wild guess)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No IE11 works fine if you set the proper content type ;)

@MorrisJobke

Copy link
Copy Markdown
Member

@MorrisJobke this is what you had in mind right?

Yes 👍

@MorrisJobke

Copy link
Copy Markdown
Member

And the unit tests fail.

@codecov

codecov Bot commented Jan 18, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #7902 into master will increase coverage by 0.15%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##             master    #7902      +/-   ##
============================================
+ Coverage     51.23%   51.39%   +0.15%     
- Complexity    24853    24856       +3     
============================================
  Files          1598     1590       -8     
  Lines         94876    94568     -308     
  Branches       1376     1376              
============================================
- Hits          48611    48601      -10     
+ Misses        46265    45967     -298
Impacted Files Coverage Δ Complexity Δ
lib/private/PreviewManager.php
core/templates/login.php
lib/private/Files/Type/Detection.php
apps/dav/appinfo/v1/publicwebdav.php
settings/ajax/disableapp.php
...s/federation/composer/composer/autoload_static.php
apps/files_sharing/js/files_drop.js
apps/dav/lib/DAV/PublicAuth.php
apps/files_trashbin/lib/Expiration.php
apps/user_ldap/lib/Mapping/UserMapping.php
... and 3176 more

@rullzer

rullzer commented Jan 18, 2018

Copy link
Copy Markdown
Member Author

And now they pass :)

@rullzer rullzer added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jan 18, 2018
Comment thread apps/files/js/filelist.js Outdated

if (typeof urlSpec.fileId !== 'undefined') {
delete urlSpec.file;
return OC.generateUrl('/core/preview.fileid?') + $.param(urlSpec);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a valid file ending please? Helps in some browsers when you right-click save stuff.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we can't. becaus I don't know what type of file we'll server png or jpeg. So whichever one we chose it can lie.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is also the behaviour of the /core/preview.png route, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But that is not an argument ;-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, just seemed odd to me that we then remove the preview route without the .png extension which would actually be the one that has a more correct 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that route didn't do anything... was just a leftover. Because we map function to route. so it was overwritten :P

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine by me, just seemed a bit inconsistent 🙈

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaah you mean like that. well sure we can also move this route to just /preview would be fine by me

Signed-off-by: Roeland Jago Douma <[email protected]>
This makes sure the preview is cached even after rename! yay!

Signed-off-by: Roeland Jago Douma <[email protected]>
@MorrisJobke
MorrisJobke merged commit 5520ba3 into master Jan 24, 2018
@MorrisJobke
MorrisJobke deleted the fix_7700 branch January 24, 2018 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants