@@ -0,0 +1,2031 @@
+package de.fu_berlin.cdv.chasingpictures.api;%0A%0Aimport android.content.Context;%0A%0Aimport org.springframework.core.io.FileSystemResource;%0Aimport org.springframework.http.HttpEntity;%0Aimport org.springframework.http.HttpMethod;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.http.converter.FormHttpMessageConverter;%0Aimport org.springframework.util.LinkedMultiValueMap;%0Aimport org.springframework.util.MultiValueMap;%0A%0Aimport java.io.File;%0A%0Aimport de.fu_berlin.cdv.chasingpictures.R;%0A%0A/**%0A * API request for sending a new photo to the back end.%0A *%0A * @author Simon Kalt%0A */%0Apublic class PhotoUploadRequest extends ApiRequest%3CPicture%3E %7B%0A    private final Place place;%0A    private final File picture;%0A%0A    public PhotoUploadRequest(Context context, Place place, File picture) %7B%0A        super(context, R.string.api_path_upload);%0A        this.place = place;%0A        this.picture = picture;%0A    %7D%0A%0A    @Override%0A    protected ResponseEntity%3CPicture%3E send() %7B%0A        // Add a form data message converter, before any others%0A        FormHttpMessageConverter formMessageConverter = new FormHttpMessageConverter();%0A        restTemplate.getMessageConverters().add(0, formMessageConverter);%0A%0A        MultiValueMap%3CString, Object%3E formData = new LinkedMultiValueMap%3C%3E(2);%0A%0A        // wrap the ID in a string, otherwise Spring won't be able to convert the value%0A        formData.set(%22place_id%22, String.valueOf(place.getId()));%0A        FileSystemResource resource = new FileSystemResource(picture);%0A%0A        // Manually set the content type header for the file%0A        MultiValueMap%3CString, String%3E fileHeaders = new LinkedMultiValueMap%3C%3E();%0A        fileHeaders.set(%22Content-Type%22, MediaType.IMAGE_JPEG_VALUE);%0A        formData.set(%22file%22, new HttpEntity%3C%3E(resource, fileHeaders));%0A%0A%0A        return restTemplate.exchange(%0A                apiUri,%0A                HttpMethod.POST,%0A                new HttpEntity%3C%3E(formData, headers),%0A                Picture.class%0A        );%0A    %7D%0A%7D%0A

Add API request for photo upload