@@ -0,0 +1,1027 @@
+package fr.alecharp.picshare.service;%0A%0Aimport com.google.inject.Singleton;%0Aimport fr.alecharp.picshare.domain.Picture;%0Aimport net.codestory.http.Part;%0A%0Aimport javax.inject.Inject;%0Aimport javax.inject.Named;%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.Optional;%0A%0A/**%0A * @author Adrien Lecharpentier%0A */%0A@Singleton%0Apublic class PictureService %7B%0A    private final String storageLocation;%0A%0A    @Inject%0A    public PictureService(@Named(%22storageLocation%22) String storageLocation) %7B%0A        this.storageLocation = storageLocation;%0A    %7D%0A%0A    public Optional%3CPicture%3E upload(String eventID, Part part) %7B%0A        try %7B%0A            Path target = Paths.get(storageLocation, eventID, part.fileName());%0A            Files.copy(part.inputStream(), target);%0A            return Optional.of(new Picture(part.fileName(), %22/%22 + target.toString()));%0A        %7D catch (IOException e) %7B%0A            // TODO: log%0A            return Optional.empty();%0A        %7D%0A    %7D%0A%7D%0A

Create service to upload pictures