Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
3d6ee7ff
Unverified
Commit
3d6ee7ff
authored
8 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Update thumbnail endpoint to new generato
Signed-off-by:
Roeland Jago Douma
<
roeland@famdouma.nl
>
parent
5d110851
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files/lib/Controller/ApiController.php
+17
-6
17 additions, 6 deletions
apps/files/lib/Controller/ApiController.php
with
17 additions
and
6 deletions
apps/files/lib/Controller/ApiController.php
+
17
−
6
View file @
3d6ee7ff
...
@@ -31,11 +31,13 @@ namespace OCA\Files\Controller;
...
@@ -31,11 +31,13 @@ namespace OCA\Files\Controller;
use
OCP\AppFramework\Http
;
use
OCP\AppFramework\Http
;
use
OCP\AppFramework\Controller
;
use
OCP\AppFramework\Controller
;
use
OCP\Files\File
;
use
OCP\Files\Folder
;
use
OCP\Files\Folder
;
use
OCP\Files\NotFoundException
;
use
OCP\IConfig
;
use
OCP\IConfig
;
use
OCP\IRequest
;
use
OCP\IRequest
;
use
OCP\AppFramework\Http\DataResponse
;
use
OCP\AppFramework\Http\DataResponse
;
use
OCP\AppFramework\Http\
Data
DisplayResponse
;
use
OCP\AppFramework\Http\
File
DisplayResponse
;
use
OCP\AppFramework\Http\Response
;
use
OCP\AppFramework\Http\Response
;
use
OCA\Files\Service\TagService
;
use
OCA\Files\Service\TagService
;
use
OCP\IPreview
;
use
OCP\IPreview
;
...
@@ -101,18 +103,27 @@ class ApiController extends Controller {
...
@@ -101,18 +103,27 @@ class ApiController extends Controller {
* @param int $x
* @param int $x
* @param int $y
* @param int $y
* @param string $file URL-encoded filename
* @param string $file URL-encoded filename
* @return DataResponse|
Data
DisplayResponse
* @return DataResponse|
File
DisplayResponse
*/
*/
public
function
getThumbnail
(
$x
,
$y
,
$file
)
{
public
function
getThumbnail
(
$x
,
$y
,
$file
)
{
if
(
$x
<
1
||
$y
<
1
)
{
if
(
$x
<
1
||
$y
<
1
)
{
return
new
DataResponse
([
'message'
=>
'Requested size must be numeric and a positive value.'
],
Http
::
STATUS_BAD_REQUEST
);
return
new
DataResponse
([
'message'
=>
'Requested size must be numeric and a positive value.'
],
Http
::
STATUS_BAD_REQUEST
);
}
}
$preview
=
$this
->
previewManager
->
createPreview
(
'files/'
.
$file
,
$x
,
$y
,
true
);
try
{
if
(
$preview
->
valid
())
{
$file
=
$this
->
userFolder
->
get
(
$file
);
return
new
DataDisplayResponse
(
$preview
->
data
(),
Http
::
STATUS_OK
,
[
'Content-Type'
=>
'image/png'
]);
if
(
$file
instanceof
Folder
)
{
}
else
{
throw
new
NotFoundException
();
}
/** @var File $file */
$preview
=
$this
->
previewManager
->
getPreview
(
$file
,
$x
,
$y
,
true
);
return
new
FileDisplayResponse
(
$preview
,
Http
::
STATUS_OK
,
[
'Content-Type'
=>
$preview
->
getMimeType
()]);
}
catch
(
NotFoundException
$e
)
{
return
new
DataResponse
([
'message'
=>
'File not found.'
],
Http
::
STATUS_NOT_FOUND
);
return
new
DataResponse
([
'message'
=>
'File not found.'
],
Http
::
STATUS_NOT_FOUND
);
}
catch
(
\Exception
$e
)
{
return
new
DataResponse
([],
Http
::
STATUS_BAD_REQUEST
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment