use of cloudinary.models.PhotoUpload in project cloudinary_java by cloudinary.
the class PhotoController method listPhotos.
@RequestMapping(value = "/", method = RequestMethod.GET)
public String listPhotos(ModelMap model) {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key photoKey = KeyFactory.createKey("photos", "album");
List<Entity> photoEntities = datastore.prepare(new Query("photo", photoKey)).asList(FetchOptions.Builder.withDefaults());
List<PhotoUpload> photos = new java.util.ArrayList<PhotoUpload>();
for (int i = 0, n = photoEntities.size(); i < n; i++) {
photos.add(new PhotoUpload(photoEntities.get(i)));
}
model.addAttribute("photos", photos);
return "photos";
}
use of cloudinary.models.PhotoUpload in project cloudinary_java by cloudinary.
the class PhotoController method directUploadPhotoForm.
@RequestMapping(value = "/direct_upload_form", method = RequestMethod.GET)
public String directUploadPhotoForm(ModelMap model) {
model.addAttribute("photoUpload", new PhotoUpload());
model.addAttribute("unsigned", false);
return "direct_upload_form";
}
use of cloudinary.models.PhotoUpload in project cloudinary_java by cloudinary.
the class PhotoController method directUnsignedUploadPhotoForm.
@SuppressWarnings("unchecked")
@RequestMapping(value = "/direct_unsigned_upload_form", method = RequestMethod.GET)
public String directUnsignedUploadPhotoForm(ModelMap model) throws Exception {
model.addAttribute("photoUpload", new PhotoUpload());
model.addAttribute("unsigned", true);
Cloudinary cld = Singleton.getCloudinary();
String preset = "sample_" + cld.apiSignRequest(ObjectUtils.asMap("api_key", cld.config.apiKey), cld.config.apiSecret).substring(0, 10);
model.addAttribute("preset", preset);
try {
Singleton.getCloudinary().api().createUploadPreset(ObjectUtils.asMap("name", preset, "unsigned", true, "folder", "preset_folder"));
} catch (Exception e) {
}
return "direct_upload_form";
}
use of cloudinary.models.PhotoUpload in project cloudinary_java by cloudinary.
the class PhotoUploadValidator method validate.
public void validate(Object obj, Errors e) {
ValidationUtils.rejectIfEmpty(e, "title", "title.empty");
PhotoUpload pu = (PhotoUpload) obj;
if (pu.getFile() == null || pu.getFile().isEmpty()) {
if (!pu.validSignature()) {
e.rejectValue("signature", "signature.mismatch");
}
}
}
Aggregations