This code is incorrect, if the file is a pdf the content type will be set to image/pdf which is incorrect