Repository navigation
[WIP] Implement thumbnailssvc - #298
TheOneRing wants to merge 2 commits into
Conversation
|
@TheOneRing can you rebase on top of master? |
b1fc50f to
6c75f33
Compare
1f3de8d to
1513631
Compare
|
@TheOneRing Hi Hannah, thanks a lot for working on this PR. If it could help you in your implementation this is what we do in CERNBox for the ownCloud preview application to generate the thumbnails: |
refs
left a comment
There was a problem hiding this comment.
👍 correct a typo. Other than that I added some small comments regarding code style that might or might not be needed.
| "github.com/rs/zerolog" | ||
| ) | ||
|
|
||
| type thumnailhandler struct { |
There was a problem hiding this comment.
If the type thumbnailHandler is not exported consider using non exported members. Here is a good read
| return nil | ||
| } | ||
| t.Size = uint(size) | ||
| return &t |
There was a problem hiding this comment.
you could make the return more explicit by using struct literal, instead of mutating t along the way 🤷
| httpClient := rhttp.GetHTTPClient(ctx) | ||
| httpReq, err := rhttp.NewRequest(ctx, "GET", t.URL, nil) | ||
| httpReq.Header = t.Request.Header.Clone() | ||
| if err != nil { |
There was a problem hiding this comment.
this should be one line above, in L:150, to save one instruction
| return | ||
| } | ||
|
|
||
| newImage := resize.Thumbnail(t.Size, t.Size, image, resize.Lanczos3) |
There was a problem hiding this comment.
I'd rename this to thumbnail to avoid confusion with the declared variable image
| TempFileName string | ||
| } | ||
|
|
||
| func newThumbnailHandler(s *svc, w http.ResponseWriter, r *http.Request) *thumnailhandler { |
There was a problem hiding this comment.
functions are package scoped. a more appropriate name would be newHandler.
In general I'd move away from postfixing this with "-Handler" as it can be read as "thumbnailHandler implements the Handler interface" source. Instead, your type thumbnailHandler is an abstraction that does not implement such interface.
You're implementing the Handler interface on your thumbnails>service.go on svc method set
| if err != nil { | ||
| t.Log.Err(err).Msg("Failed to partse host: " + s.conf.WebDavHost) | ||
| t.Writer.WriteHeader(http.StatusInternalServerError) | ||
| return nil |
There was a problem hiding this comment.
For the time being it does the job, but I wonder if it'd be possible not having this side effects, or decoupling the side effects from t and instead of mutating t along the body of the function, instead return a composite struct literal with the fields filled. It makes the logic easier to follow.
af2c675 to
13ea4b5
Compare
| _ "github.com/cs3org/reva/internal/http/services/owncloud/ocdav" | ||
| _ "github.com/cs3org/reva/internal/http/services/owncloud/ocs" | ||
| _ "github.com/cs3org/reva/internal/http/services/prometheus" | ||
| _ "github.com/cs3org/reva/internal/http/services/thumbnails" |
There was a problem hiding this comment.
@TheOneRing can you put the service also under owncloud like the ocdav and ocs are? Thanks!
9520678 to
f4ced19
Compare
f4ced19 to
c1b5642
Compare
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.32.0 to 0.33.0. - [Commits](golang/sys@v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
No description provided.