Я пытаюсь использовать тип S3Blob для отправки файла фотографии в корзину S3. Просто пытаюсь запустить мое приложение локально, и я получаю следующую ошибку компиляции в моей функции doCreateItem.
Compilation error (In /app/controllers/Application.java around line 45)
The file /app/controllers/Application.java could not be compiled. Error raised is : The constructor FileInputStream(S3Blob) is undefined
Я явно импортировал java .io.FileInputStream в приложении. java
Приложение. java
package controllers;
import com.google.gson.JsonObject;
import play.*;
import play.mvc.*;
import java.util.*;
import java.util.List;
import models.*;
import play.data.validation.*;
import play.libs.MimeTypes;
import java.util.Date;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import play.modules.s3blobs.S3Blob;
public class Application extends Controller {
public static void index() {
List<AuctionItem> mostPopular = AuctionItem.getMostPopular(5);
List<AuctionItem> endingSoon = AuctionItem.getEndingSoon(5);
render(mostPopular, endingSoon);
}
public static void createAuctionItem(){
if(session.get("user") == null){
Authenticate.login();
}
render();
}
public static void doCreateItem(@Valid AuctionItem item){
if (validation.hasErrors()){
params.flash();
validation.keep();
createAuctionItem();
}
item.createdBy = Authenticate.getLoggedInUser();
item.photo = new S3Blob();
*Line45 item.photo.set(new FileInputStream(item.photo), MimeTypes.getContentType(item.photo.getName()));
item.save();
show(item.id);
}
public static void show(Long id){
AuctionItem item = AuctionItem.findById(id);
item.viewCount++;
item.save();
render(item);
}
public static void showImage(Long id){
AuctionItem item = AuctionItem.findById(id);
renderBinary(item.photo.get());
}
public static void search(String search, Integer page){
validation.required(search).message("You must enter something to search for.");
if (validation.hasErrors()){
render();
}
if (page == null) page = 1;
SearchResults results = AuctionItem.search(search, page);
render(results, page, search);
}
}
AuctionItem. java
package models;
import play.db.jpa.Model;
import play.modules.s3blobs.S3Blob;
import play.data.validation.*;
import javax.persistence.*;
import java.util.*;
import play.db.jpa.Blob;
@Entity
public class AuctionItem extends Model {
@Required
public String title;
public Date startDate;
public Date endDate;
@Required
public Float deliveryCost;
@Required
public Float startBid;
@Required
public Float buyNowPrice;
// public Boolean buyNowEnabled;
@Column(length=4096)
@Required
@MinSize(20)
public String description;
public Integer viewCount = 0;
@Transient
@Required
public Integer days;
public S3Blob photo;
@ManyToOne
public User createdBy;
public void setDays(Integer days){
this.days = days;
if (days != null){
startDate = new Date();
// endDate = new Date(System.currentTimeMillis() + (days * 24*60*60*1000));
endDate = new Date(System.currentTimeMillis() + (days * 24*60*60*1000));
}
}
public Float getCurrentTopBid(){
return startBid;
}
public static List<AuctionItem> getMostPopular(int maxItems){
return find("endDate > ? order by viewCount DESC", new Date()).fetch(maxItems);
}
public static List<AuctionItem> getEndingSoon(int maxItems){
return find("endDate > ? order by endDate ASC", new Date()).fetch(maxItems);
}
public static SearchResults search(String search, Integer page){
String likeSearch ="%"+search+"%";
long count =count("title like ? OR description like ? AND " + "endDate > ?",likeSearch,likeSearch, new Date());
List<AuctionItem>items = find("title like ? OR description like ? AND endDate > ? " + "order by endDate ASC", likeSearch, likeSearch, new Date()).fetch(page, 20);
return new SearchResults(items, count);
}
}
Где я тут ошибся? Спасибо, Ironman