{"id":341742,"date":"2022-11-25T15:00:44","date_gmt":"2022-11-25T15:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341742"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341742","title":{"rendered":"<span>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445?<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 Naumen, \u043d\u0435 \u0437\u043d\u0430\u043b\u0430, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u043c\u043e\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435, \u0438 \u043a\u0430\u043a \u0444\u0430\u0439\u043b\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.\u00a0<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043c\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0438 \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u043c \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0431\u0430\u0437\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0438 \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043b\u0438 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<div class=\"persona\" persona=\"true\"><img decoding=\"async\" persona=\"true\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/b1c\/e0e\/286\/b1ce0e28602d135e21c16fe285fd7c77.jpg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b1c\/e0e\/286\/b1ce0e28602d135e21c16fe285fd7c77.jpg\" data-blurred=\"true\"\/><\/p>\n<h5 class=\"persona__heading\" persona=\"true\">\u041c\u0430\u0440\u0438\u044f \u0410\u043c\u0435\u043d\u0434<\/h5>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 Naumen<\/p>\n<\/div>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u2014 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0442\u0438, \u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0448\u0430 \u0411\u0414 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0437\u0431\u0443\u0445\u0430\u0442\u044c. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u043d\u0438\u043c\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0411\u0414;<\/p>\n<\/li>\n<li>\n<p>\u0411\u0414 \u0434\u043e\u043b\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u044d\u043a\u0430\u043f\u0430 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430. \u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0424\u0425, \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0424\u0425 \u2014 \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0438\u043b\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0434\u0438\u0441\u043a\u0435, \u0433\u0434\u0435 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b.\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/836\/a93\/7fa\/836a937facead95d7c3734815bf8b05f.jpg\" width=\"1171\" height=\"587\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/836\/a93\/7fa\/836a937facead95d7c3734815bf8b05f.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c<\/h2>\n<h3>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0424\u0425 S3 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.\u00a0<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FXOperations fxOperations;   private final FileDao fileDao;   @Inject   public FileController(FXOperations fxOperations, FileDao fileDao)   {     this.fxOperations = fxOperations;     this.fileDao = fileDao;   }   public void save(java.io.File fileForSave) throws FileNotFoundExceptions   {     File file = new File(fileForSave.getName());     fxOperation.save(fileForSave.getName(), new FileInputStream(fileForSave), fileForSave.length());(fileForSave.getName(), new FileInputStream(FileForSave), fileForSave.length());     fileDao.save(file);   }  \/\/ get delete }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 FileController, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448 \u0444\u0440\u043e\u043d\u0442. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File, \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432. \u041f\u043e\u0442\u043e\u043c \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0431\u0430\u0437\u0443 \u0441\u0430\u043c\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u0430.  <\/p>\n<pre><code class=\"java\">public class File  {   private long id;   private String name;    public File(String Name) { this.name = name; }    \/\/region getter-setter   public long getId() { return id; }    public void setId(long id) { this.id = id; }    public String getName() { return name; }    public void setName(String name) { this.name = name; } \/\/ endregion getter-setter }<\/code><\/pre>\n<p>File \u2014 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0430\u0439\u043b \u0432 \u0424\u0425. \u041f\u043e \u0441\u0443\u0442\u0438, \u0432 \u043f\u043e\u043b\u0435 name \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043b\u0435\u0433\u043a\u043e \u0435\u0433\u043e \u043d\u0430\u0439\u0442\u0438. \u042d\u0442\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c FileDao, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0432 \u0411\u0414.<\/p>\n<pre><code>@Component public class FileDao {   public void save(File obj) { return; } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e FXOperations.  <\/p>\n<pre><code class=\"java\">@Component public class FXOperations {   private Finall AmazonS3 amazonS3 = AmazonS3ClientBuilder .standard() .withCredentials(new AWSStaticCredentialsProvider(       new BasicAWSCredentials(\"access_key\", \"secret_key\"))) .build();    public void save(String filePath, InputStream content, long size)   {     String bucketName = \"default\";     ObjectMetadata metadata = new ObjectMetadata();     metadata.setContentLength(size);      amazonS3.putObject(bucketName, filePath, content, metadata);   }    \/\/get delete }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0424\u0425 S3 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u044e \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0424\u0425, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 accessKey, secretKey \u2014 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0424\u0425.<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0424\u0425. \u042d\u0442\u043e bucketName, \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 filePath, content \u0438 metadata. Metadata \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 (size), \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 File, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f. \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0424\u0425 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0441\u0430\u043c\u0443 \u0411\u0414.<\/p>\n<pre><code>File file = new File(fileForSave.getName()); fxOperation.save(fileForSave.getName(), new FileInputStream(fileForSave), fileForSave.lenght()); fileDao.save(file);<\/code><\/pre>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0424\u0425: \u0435\u0441\u043b\u0438 \u0424\u0425 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e, \u0438\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u043f\u043b\u043e\u0445\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043b\u0433\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u043a\u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  <\/h3>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u2192 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414 \u2192 \u043f\u043e\u0442\u043e\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425.\u00a0<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: \u0444\u0430\u0439\u043b \u043d\u0430\u0434\u0435\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0411\u0414. \u0417\u0430\u0442\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0444\u0430\u0439\u043b \u0438\u0437 \u0411\u0414 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0424\u0425, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0442\u0443\u0434\u0430.<\/p>\n<p>\u0422\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FXOperations fxOperations;   private final FileDao fileDao;    @Inject   public FileController(FXOperations fxOperations, FileDao fileDao)   {     this.fxOperations = fxOperations;     this.fileDao = fileDao;   }    public void save(java.io.File fileForSave) throws FileNotFoundException   {     File file = new File(                fileForSave.getName(),                new FileInputStream(fileForSave),                fileForSave.length(),                false);     fileDao.save(file);      new Thread(() ->     {         fxOperations.save(file);         file.setInputStream(null);         fileDao.save(file);     }).start();     }   } }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c FileController, \u043e\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0412 \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f, \u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c content, \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c, \u0433\u0434\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u2014 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438\u043b\u0438 \u0435\u0449\u0435 \u0432 \u0411\u0414. \u041d\u0443 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u043d\u0430\u0448 \u0444\u0430\u0439\u043b. \u0410 \u0437\u0430\u0442\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0424\u0425, \u0438 \u0443 \u043d\u0430\u0441 \u0432 \u0431\u0430\u0437\u0435 \u043d\u0435\u0442 \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0418 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0432 \u0411\u0414.<\/p>\n<p>\u0421\u0430\u043c \u0444\u0430\u0439\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414. \u0421\u0430\u043c\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c FileDao \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e FXOperations \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<pre><code class=\"java\">public class File {     private long id;     private String name;     private InputStream inputStream;     private long size;     private boolean isFX;      public File(String name, InputStream inputStream, long size, boolean isFX)     {           this.name = name;           this.InputStream = inputStream;           this.size = size;           this.isFX = isFX;     }      \/\/region getter-setter     public long getId() { return id; }      public String getName() { return name; }      public InputStream getInputStream() { return inputStream; } }<\/code><\/pre>\n<p>\u0421\u0430\u043c\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c FileDao \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e FXOperations \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c.  <\/p>\n<pre><code class=\"java\">@Component public class FXOperations {   private final AmazonS3 amazonS3 = AmazonS3ClientBuilder            .standard()            .withCredentials(new AWSStaticCredentialsProvider(                    new basicAWSCredentials(\"access_key\", \"secret_key\")));            .build();    public void save(File file)   {     String filePath = file.getName();     InputStream content = file.getInputStream();     long size = file.getSize();     String bucketName = \"default\"     final ObjectMetadata metadata = new ObjectMetadata();     metadata.setContentLength(size);      amazonS3.putObject(bucketName, filePath, content, metadata);   }    \/\/get delete }<\/code><\/pre>\n<p>\u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u043a. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0440\u0435\u0448\u0430\u0442 \u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0443\u043f\u0430\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u0424\u0425, \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u0435. \u041d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<h3>\u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  <\/h3>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u2192 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414 \u0438 \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u2192 \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0444\u0430\u0439\u043b \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0434\u043b\u044f \u043d\u0430\u0441 \u0432\u0440\u0435\u043c\u044f \u0443\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u043f\u0430\u0447\u043a\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FileDao fileDao;    @Inject   public FileController(FileDao fileDao) { this.fileDao = fileDao: }    public void save(java.io.File fileForSave) throws FileNotFoundExceptions   {     File file = new File(                      fileForSave.getName(),                      new FileInputStream(fileForSave),                      fileForSave.length(),                      false);     fileDao.save(file);   }    \/\/ get delete }         <\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c FileController, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u0430. \u0417\u0434\u0435\u0441\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u0430\u0448\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043f\u043e\u043b\u044f. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u2014 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 MoveJob. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437 \u0432 30 \u0441\u0435\u043a\u0443\u043d\u0434.\u00a0<\/p>\n<pre><code>@Component public class MoveJob {   private final FileDao fileDao;   private final FXOperations fxOperations;    @Inject   public MoveJob(FileDao fileDao, FXOperations fxOperations)   {     this.fileDao = fileDao;     this.fxOperations = dxOperations;   }    @Scheduled(fixedDelay = 30000)   public void move()   {     List&lt;File> files = fileDao.getFiles(10);      for (File file : files)     {       fxOperations.save(file);       file.setFX(true);       file.setInputStream(null);       fileDao.save(file);     }   } }<\/code><\/pre>\n<p>\u0412 FileDao \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434: \u043c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f 10 \u0444\u0430\u0439\u043b\u043e\u0432. \u041b\u043e\u0433\u0438\u043a\u0443 \u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 select \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 10 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0424\u0425.<\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0444\u0430\u0439\u043b \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0424\u0425, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e. \u0414\u0440\u0443\u0433\u043e\u0435 \u0434\u0435\u043b\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0430\u0439\u043b\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0435: \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0444\u0430\u0439\u043b\u044b \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u042d\u0442\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0431\u043b\u0438\u0436\u0435.<\/p>\n<h3>\u0427\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c?  <\/h3>\n<ul>\n<li>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0447\u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043f\u0440\u0438 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0444\u0430\u0439\u043b\u044b \u0440\u044f\u0434\u043e\u043c.\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0430 \u0434\u0438\u0441\u043a\u0435.\u00a0<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0435. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u2192 \u043c\u044b \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0411\u0414 \u2192 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 \u0424\u0425, \u043d\u043e \u0441 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u0442\u0441\u044f \u043d\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b. \u041c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043c\u043e\u0436\u043d\u043e \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FileDao fileDao;    @Inject   public FileController(FileDao fileDao) { this.fileDao = fileDao; }    public void save(java.io.File fileForSave) throws FileNotFoundException   {     saveFile(fileForSave, false);   }    public void saveSystem(java.io.File fileForSave) throws FileNotFoundException   {     saveFile(fileForSave, true);   }    public void saveFile(java.io.File fileForSave, boolean isSystem) throws FileNotFound   {     File file = new File(                 fileForsave.getName(),                 new FileInputStream(fileForSave),                 fileForSave.length(),                 false,                 isSystem);     fileDao.save(file);   } }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 FileController \u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 save \u0438 saveSystem. \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 save, \u0437\u043d\u0430\u0447\u0438\u0442, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u2014 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0439. \u042f \u0432\u044b\u043d\u0435\u0441\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043e\u043d\u0430 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c, \u043a\u0440\u043e\u043c\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0441\u0442\u0438 \u0444\u0430\u0439\u043b\u0430.  <\/p>\n<pre><code class=\"java\">@Component  public class MoveJob implements Runnable {   private final FileDao fileDao;   private final FXOperations fxOperations;     @Inject   public MoveJob(FileDao fileDao, FXOperations fxOperations)   {     this.fileDao = fileDao;     this.fxOperations = fxOperations;   }    @Override   public void run()   {     List&lt;File> files = fileDao.getFiles(10, false);      for (File file : files)     {       fxOperations.save(file);       file.setFX(true);       file.setInputStream(null);       fileDao.save(file);     }   } }<\/code><\/pre>\n<p>\u0421\u0430\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u043f\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u0412 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0432\u043a\u043b\u044e\u0447\u0430\u0439 \u0432\u0441\u0435 \u043d\u0435\u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u041f\u043e\u0442\u043e\u043c \u043c\u044b \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u043d\u0438\u043c \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432 \u0424\u0425.\u00a0<\/p>\n<p>\u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442. <\/p>\n<h2>\u041f\u043b\u044e\u0448\u043a\u0438<\/h2>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0442\u0430\u0439\u043c-\u0430\u0443\u0442\u0430<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0448\u0435\u043c\u0443 \u0424\u0425 \u043f\u043b\u043e\u0445\u043e, \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0434\u043e\u043b\u0431\u0438\u0442\u044c \u0435\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u0435\u0440\u0435\u0440\u044b\u0432 \u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443.<\/p>\n<h4>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0424\u0425<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u0424\u0425 \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432, \u043c\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0410 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u044b. \u041b\u0438\u0431\u043e \u0435\u0441\u043b\u0438 \u043e\u0434\u043d\u043e\u043c\u0443 \u0424\u0425 \u0441\u0442\u0430\u043b\u043e \u043f\u043b\u043e\u0445\u043e, \u043c\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0435 \u0424\u0425 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043d\u0438\u043c, \u043f\u043e\u043a\u0430 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c.<\/p>\n<p>\u0424\u0425 \u2014 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043c\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u043e\u0432. \u041c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0443, \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0411\u0414, \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0444\u0430\u0439\u043b \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/naumen\/blog\/701616\/\"> https:\/\/habr.com\/ru\/company\/naumen\/blog\/701616\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 Naumen, \u043d\u0435 \u0437\u043d\u0430\u043b\u0430, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043a\u0430\u043a \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u043c\u043e\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u0438\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435, \u0438 \u043a\u0430\u043a \u0444\u0430\u0439\u043b\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.\u00a0<\/p>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043c\u044b \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0438 \u043d\u0435 \u0443\u043f\u0430\u0434\u0435\u043c \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u043c\u0438. \u041f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0431\u0430\u0437\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0438 \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0438\u043b\u0438 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.<\/p>\n<div class=\"persona\" persona=\"true\">\n<h5 class=\"persona__heading\" persona=\"true\">\u041c\u0430\u0440\u0438\u044f \u0410\u043c\u0435\u043d\u0434<\/h5>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 Naumen<\/p>\n<\/div>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432, \u043f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u2014 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0444\u0430\u0439\u043b\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0440\u0430\u0441\u0442\u0438, \u0430 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u0448\u0430 \u0411\u0414 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0437\u0431\u0443\u0445\u0430\u0442\u044c. \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0442\u0440\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ul>\n<li>\n<p>\u0417\u0430\u043d\u0438\u043c\u0430\u0435\u043c \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0411\u0414;<\/p>\n<\/li>\n<li>\n<p>\u0411\u0414 \u0434\u043e\u043b\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0412\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u044d\u043a\u0430\u043f\u0430 \u0443\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430. \u0412 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u043c\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0445 \u0424\u0425, \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u043e.<\/p>\n<p>\u0424\u0425 \u2014 \u044d\u0442\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0438\u043b\u0438 \u0441\u0435\u0442\u0435\u0432\u043e\u043c \u0434\u0438\u0441\u043a\u0435, \u0433\u0434\u0435 \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b.\u00a0<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c<\/h2>\n<h3>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0424\u0425 S3 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.\u00a0<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FXOperations fxOperations;   private final FileDao fileDao;   @Inject   public FileController(FXOperations fxOperations, FileDao fileDao)   {     this.fxOperations = fxOperations;     this.fileDao = fileDao;   }   public void save(java.io.File fileForSave) throws FileNotFoundExceptions   {     File file = new File(fileForSave.getName());     fxOperation.save(fileForSave.getName(), new FileInputStream(fileForSave), fileForSave.length());(fileForSave.getName(), new FileInputStream(FileForSave), fileForSave.length());     fileDao.save(file);   }  \/\/ get delete }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 FileController, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448 \u0444\u0440\u043e\u043d\u0442. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File, \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432. \u041f\u043e\u0442\u043e\u043c \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u0431\u0430\u0437\u0443 \u0441\u0430\u043c\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u0430.  <\/p>\n<pre><code class=\"java\">public class File  {   private long id;   private String name;    public File(String Name) { this.name = name; }    \/\/region getter-setter   public long getId() { return id; }    public void setId(long id) { this.id = id; }    public String getName() { return name; }    public void setName(String name) { this.name = name; } \/\/ endregion getter-setter }<\/code><\/pre>\n<p>File \u2014 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0430\u0439\u043b \u0432 \u0424\u0425. \u041f\u043e \u0441\u0443\u0442\u0438, \u0432 \u043f\u043e\u043b\u0435 name \u043c\u044b \u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u043b\u0435\u0433\u043a\u043e \u0435\u0433\u043e \u043d\u0430\u0439\u0442\u0438. \u042d\u0442\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c FileDao, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0432 \u0411\u0414.<\/p>\n<pre><code>@Component public class FileDao {   public void save(File obj) { return; } }<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u2014 \u044d\u0442\u043e FXOperations.  <\/p>\n<pre><code class=\"java\">@Component public class FXOperations {   private Finall AmazonS3 amazonS3 = AmazonS3ClientBuilder .standard() .withCredentials(new AWSStaticCredentialsProvider(       new BasicAWSCredentials(\"access_key\", \"secret_key\"))) .build();    public void save(String filePath, InputStream content, long size)   {     String bucketName = \"default\";     ObjectMetadata metadata = new ObjectMetadata();     metadata.setContentLength(size);      amazonS3.putObject(bucketName, filePath, content, metadata);   }    \/\/get delete }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0424\u0425 S3 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u044e \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0424\u0425, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0437 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 accessKey, secretKey \u2014 \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0424\u0425.<\/p>\n<p>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u043b\u044f \u0424\u0425. \u042d\u0442\u043e bucketName, \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 filePath, content \u0438 metadata. Metadata \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0444\u0430\u0439\u043b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0444\u0430\u0439\u043b\u0430 (size), \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435. \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 File, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f. \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0424\u0425 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0441\u0430\u043c\u0443 \u0411\u0414.<\/p>\n<pre><code>File file = new File(fileForSave.getName()); fxOperation.save(fileForSave.getName(), new FileInputStream(fileForSave), fileForSave.lenght()); fileDao.save(file);<\/code><\/pre>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435, \u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0424\u0425: \u0435\u0441\u043b\u0438 \u0424\u0425 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e, \u0438\u043b\u0438 \u0443 \u043d\u0435\u0433\u043e \u043f\u043b\u043e\u0445\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u043b\u0433\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u043a\u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<h3>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  <\/h3>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u2192 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414 \u2192 \u043f\u043e\u0442\u043e\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425.\u00a0<\/p>\n<p>\u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f: \u0444\u0430\u0439\u043b \u043d\u0430\u0434\u0435\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 \u0411\u0414. \u0417\u0430\u0442\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0444\u0430\u0439\u043b \u0438\u0437 \u0411\u0414 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438 \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0424\u0425, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0442\u0443\u0434\u0430.<\/p>\n<p>\u0422\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FXOperations fxOperations;   private final FileDao fileDao;    @Inject   public FileController(FXOperations fxOperations, FileDao fileDao)   {     this.fxOperations = fxOperations;     this.fileDao = fileDao;   }    public void save(java.io.File fileForSave) throws FileNotFoundException   {     File file = new File(                fileForSave.getName(),                new FileInputStream(fileForSave),                fileForSave.length(),                false);     fileDao.save(file);      new Thread(() ->     {         fxOperations.save(file);         file.setInputStream(null);         fileDao.save(file);     }).start();     }   } }<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c FileController, \u043e\u043d \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f. \u0412 \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430 \u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u0438\u043c\u044f, \u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c content, \u0440\u0430\u0437\u043c\u0435\u0440 \u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u043c, \u0433\u0434\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b \u2014 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0438\u043b\u0438 \u0435\u0449\u0435 \u0432 \u0411\u0414. \u041d\u0443 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u0412 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425. \u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u043d\u0430\u0448 \u0444\u0430\u0439\u043b. \u0410 \u0437\u0430\u0442\u0435\u043c, \u043f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u043c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u0444\u0430\u0439\u043b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0424\u0425, \u0438 \u0443 \u043d\u0430\u0441 \u0432 \u0431\u0430\u0437\u0435 \u043d\u0435\u0442 \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0418 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0432 \u0411\u0414.<\/p>\n<p>\u0421\u0430\u043c \u0444\u0430\u0439\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414. \u0421\u0430\u043c\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c FileDao \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e FXOperations \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c.<\/p>\n<pre><code class=\"java\">public class File {     private long id;     private String name;     private InputStream inputStream;     private long size;     private boolean isFX;      public File(String name, InputStream inputStream, long size, boolean isFX)     {           this.name = name;           this.InputStream = inputStream;           this.size = size;           this.isFX = isFX;     }      \/\/region getter-setter     public long getId() { return id; }      public String getName() { return name; }      public InputStream getInputStream() { return inputStream; } }<\/code><\/pre>\n<p>\u0421\u0430\u043c\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c FileDao \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c. \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e FXOperations \u2014 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0436\u043d\u0438\u043c.  <\/p>\n<pre><code class=\"java\">@Component public class FXOperations {   private final AmazonS3 amazonS3 = AmazonS3ClientBuilder            .standard()            .withCredentials(new AWSStaticCredentialsProvider(                    new basicAWSCredentials(\"access_key\", \"secret_key\")));            .build();    public void save(File file)   {     String filePath = file.getName();     InputStream content = file.getInputStream();     long size = file.getSize();     String bucketName = \"default\"     final ObjectMetadata metadata = new ObjectMetadata();     metadata.setContentLength(size);      amazonS3.putObject(bucketName, filePath, content, metadata);   }    \/\/get delete }<\/code><\/pre>\n<p>\u041c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0438\u043a\u043e\u0432\u044b\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u043a. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0440\u0435\u0448\u0430\u0442 \u0440\u0430\u0437\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0443\u043f\u0430\u0434\u0435\u0442 \u043b\u0438\u0431\u043e \u0424\u0425, \u043b\u0438\u0431\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u0441\u044f, \u043b\u0438\u0431\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u0435. \u041d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<h3>\u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438  <\/h3>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u2192 \u043c\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0411\u0414 \u0438 \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u2192 \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0444\u0430\u0439\u043b \u0438\u0437 \u0411\u0414 \u0432 \u0424\u0425. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0434\u043b\u044f \u043d\u0430\u0441 \u0432\u0440\u0435\u043c\u044f \u0443\u0434\u043e\u0431\u043d\u044b\u043c\u0438 \u043f\u0430\u0447\u043a\u0430\u043c\u0438.<\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code class=\"java\">@Component public class FileController {   private final FileDao fileDao;    @Inject   public FileController(FileDao fileDao) { this.fileDao = fileDao: }    public void save(java.io.File fileForSave) throws FileNotFoundExceptions   {     File file = new File(                      fileForSave.getName(),                      new FileInputStream(fileForSave),                      fileForSave.length(),                      false);     fileDao.save(file);   }    \/\/ get delete }         <\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c FileController, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0444\u0430\u0439\u043b\u0430. \u0417\u0434\u0435\u0441\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043d\u0430\u0448\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c File \u0438\u043c\u0435\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043f\u043e\u043b\u044f. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u2014 \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 MoveJob. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437 \u0432 30 \u0441\u0435\u043a\u0443\u043d\u0434.\u00a0<\/p>\n<pre><code>@Component public class MoveJob {   private final FileDao fileDao;   private final FXOperations fxOperations;    @Inject   public MoveJob(FileDao fileDao, FXOperations fxOperations)   {     this.fileDao = fileDao;     this.fxOperations = dxOperations;   }    @Scheduled(fixedDelay = 30000)   public void move()   {     List&lt;File> files = fileDao.getFiles(10);      for (File file : files)     {       fxOperations.save(file);       file.setFX(true);       file.setInputStream(null);       fileDao.save(file);     }   } }<\/code><\/pre>\n<p>\u0412 FileDao \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434: \u043c\u0435\u0442\u043e\u0434 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f 10 \u0444\u0430\u0439\u043b\u043e\u0432. \u041b\u043e\u0433\u0438\u043a\u0443 \u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 select \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 10 \u0444\u0430\u0439\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c \u0432 \u0424\u0425.<\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0444\u0430\u0439\u043b \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0424\u0425, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e. \u0414\u0440\u0443\u0433\u043e\u0435 \u0434\u0435\u043b\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0444\u0430\u0439\u043b\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0435: \u0444\u0430\u0439\u043b\u044b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0444\u0430\u0439\u043b\u044b \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b. \u042d\u0442\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0431\u043b\u0438\u0436\u0435.<\/p>\n<h3>\u0427\u0442<\/h><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341742","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341742"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341742\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}