Bitbacket server hook for working with images

Roman Norman
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 20, 2018

I'm new to Bitbucket and never wrote hooks before. There was a problem when you commit images like png, which can be very large for their resolution. I need to write a Pre-Receive server hook to check the resolution of the image. After that I want to impose a restriction, for example:

100x100 - the max size is 0.5 Mb

1000x1000 - the max size is 3 MB

Advise what is best to use for a Bitbucket server for this. 

1 answer

0 votes
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2018

Hi Roman,

Have you already checked the File Hooks Plugin app?

While it does not cover your exact use case it already contains a check on the file size and, by adding the required logic, you should be able to get the required logic working.

The source code for this app is publicly available here.

 

Thanks, Caterina - Atlassian

Tim Black
Contributor
November 14, 2019

@Caterina as you said this plugin appears to only support filtering commits based on file size and name. I suppose it might be useful to Roman to use the size option.

I'm interested in solving a similar problem, which may help Roman as well: I want to make a pre-commit local hook, or possible a server-side pre-receive hook that compresses all .png files in the commit.

This is the only thread I could find in the Community thread on the topic of image-related hooks. There are several on other git repo communities, and I'm considering just implementing my own local pre-commit hook using a commandline tool like pngcrush, etc, to automatically compress .png files.

Let me know if you have any other ideas on how to do this server side.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events