embulk-output-ftp 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db87448f5b289f68ebb6c9d03b36f295a0139ac0
4
- data.tar.gz: ab5abab07a3bec49eed5ec362c8fdec549564d88
3
+ metadata.gz: 3b64ed089208e577c405d228e5c0f5229e667587
4
+ data.tar.gz: d1cc2104d30d5451df24596199ea9383b09d0da9
5
5
  SHA512:
6
- metadata.gz: 7281539145640359c6c084c031b7a212efd3044755e57ea5b823f5a4b80635facf0c0f300e59fdf1ced7db7425104a0fdd0f737de7274674a0fba93987b4d8b5
7
- data.tar.gz: a2d49e39e67f7c5c680e62651db9ccf6e845bc42e317d81a834d52e9c83a3630003b10667f304fc4351e637f74bb9304b985510d688d5b39db86d837b89eb4de
6
+ metadata.gz: 90f8c88a80c849c15584780a865c7bd9ca2cb9d538108265364f717eff007c570aa9bbd48b1e30baa66b1681eab314abdeae6098ed5cbdbc40889cc59ddf3fba
7
+ data.tar.gz: d9548123c3a9ddd42d165769fd24a8f9bb22e4eb3ad08922bd131ea4db009eebb4c0c79b7510880157b9a2106bcb8c0e5292a1d88204594407cda059bdbba7e1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.2 - 2016-07-21
2
+
3
+ * [maintenance] Force to create remote directory if remote directory doesn't exists. [#2](https://github.com/sakama/embulk-output-ftp/pull/2)
4
+ * [maintenance] Add additional environmental variables for unit test. [#3](https://github.com/sakama/embulk-output-ftp/pull/3)
5
+
1
6
  ## 0.1.1 - 2016-07-20
2
7
 
3
8
  * [maintenance] Add unit test, refactoring, change logging logic
data/README.md CHANGED
@@ -115,6 +115,12 @@ FTP_TEST_SSL_TRUSTED_CA_CERT_FILE
115
115
  FTP_TEST_SSL_TRUSTED_CA_CERT_DATA
116
116
  ```
117
117
 
118
+ Following option is optional
119
+ ```
120
+ FTP_TEST_PORT (default:21)
121
+ FTP_TEST_SSL__PORT (default:990)
122
+ ```
123
+
118
124
  If you're using Mac OS X El Capitan and GUI Applications(IDE), like as follows.
119
125
  ```xml
120
126
  $ vi ~/Library/LaunchAgents/environment.plist
data/build.gradle CHANGED
@@ -14,7 +14,7 @@ configurations {
14
14
  provided
15
15
  }
16
16
 
17
- version = "0.1.1"
17
+ version = "0.1.2"
18
18
 
19
19
  sourceCompatibility = 1.7
20
20
  targetCompatibility = 1.7
@@ -65,7 +65,7 @@ Gem::Specification.new do |spec|
65
65
  spec.version = "${project.version}"
66
66
  spec.authors = ["Satoshi Akama"]
67
67
  spec.summary = %[FTP file output plugin for Embulk]
68
- spec.description = %[Stores files on FTP.]
68
+ spec.description = %[Store files using FTP.]
69
69
  spec.email = ["satoshiakama@gmail.com"]
70
70
  spec.licenses = ["Apache 2.0"]
71
71
  spec.homepage = "https://github.com/sakama/embulk-output-ftp"
@@ -36,6 +36,8 @@ import java.io.FileNotFoundException;
36
36
  import java.io.FileOutputStream;
37
37
  import java.io.IOException;
38
38
  import java.net.URISyntaxException;
39
+ import java.nio.file.Path;
40
+ import java.nio.file.Paths;
39
41
  import java.util.List;
40
42
 
41
43
  public class FtpFileOutputPlugin implements FileOutputPlugin
@@ -145,6 +147,7 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
145
147
  private int fileIndex;
146
148
  private File file;
147
149
  private String filePath;
150
+ private String remoteDirectory;
148
151
  private int taskIndex;
149
152
 
150
153
  public FtpFileOutput(FTPClient client, PluginTask task, int taskIndex)
@@ -168,7 +171,8 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
168
171
  suffix = "." + suffix;
169
172
  }
170
173
  filePath = pathPrefix + String.format(sequenceFormat, taskIndex, fileIndex) + suffix;
171
- file = Exec.getTempFileSpace().createTempFile(filePath, ".tmp");
174
+ remoteDirectory = getRemoteDirectory(filePath);
175
+ file = Exec.getTempFileSpace().createTempFile(filePath, "tmp");
172
176
  log.info("Writing local temporary file \"{}\"", file.getAbsolutePath());
173
177
  output = new BufferedOutputStream(new FileOutputStream(file));
174
178
  }
@@ -225,9 +229,15 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
225
229
  public Void call() throws FTPIllegalReplyException, FTPException, FTPDataTransferException,
226
230
  FTPAbortedException, IOException, RetryGiveupException
227
231
  {
232
+ try {
233
+ client.changeDirectory(remoteDirectory);
234
+ }
235
+ catch (FTPException e) {
236
+ client.createDirectory(remoteDirectory);
237
+ }
228
238
  client.upload(filePath,
229
- new BufferedInputStream(new FileInputStream(file)), 0L, 0L,
230
- new LoggingTransferListener(file.getAbsolutePath(), filePath, log, TRANSFER_NOTICE_BYTES)
239
+ new BufferedInputStream(new FileInputStream(file)), 0L, 0L,
240
+ new LoggingTransferListener(file.getAbsolutePath(), filePath, log, TRANSFER_NOTICE_BYTES)
231
241
  );
232
242
  if (!file.delete()) {
233
243
  throw new ConfigException("Couldn't delete local file " + file.getAbsolutePath());
@@ -290,6 +300,12 @@ public class FtpFileOutputPlugin implements FileOutputPlugin
290
300
  {
291
301
  return Exec.newTaskReport();
292
302
  }
303
+
304
+ private String getRemoteDirectory(String filePath)
305
+ {
306
+ Path path = Paths.get(filePath);
307
+ return path.getParent().toString();
308
+ }
293
309
  }
294
310
 
295
311
  private static FTPClient newFTPClient(Logger log, PluginTask task)
@@ -46,6 +46,8 @@ import java.util.List;
46
46
  public class TestFtpFileOutputPlugin
47
47
  {
48
48
  private static String FTP_TEST_HOST;
49
+ private static Integer FTP_TEST_PORT;
50
+ private static Integer FTP_TEST_SSL_PORT;
49
51
  private static String FTP_TEST_USER;
50
52
  private static String FTP_TEST_PASSWORD;
51
53
  private static String FTP_TEST_SSL_TRUSTED_CA_CERT_FILE;
@@ -65,6 +67,8 @@ public class TestFtpFileOutputPlugin
65
67
  public static void initializeConstant()
66
68
  {
67
69
  FTP_TEST_HOST = System.getenv("FTP_TEST_HOST");
70
+ FTP_TEST_PORT = System.getenv("FTP_TEST_PORT") != null ? Integer.valueOf(System.getenv("FTP_TEST_PORT")) : 21;
71
+ FTP_TEST_SSL_PORT = System.getenv("FTP_TEST_SSL_PORT") != null ? Integer.valueOf(System.getenv("FTP_TEST_SSL_PORT")) : 990;
68
72
  FTP_TEST_USER = System.getenv("FTP_TEST_USER");
69
73
  FTP_TEST_PASSWORD = System.getenv("FTP_TEST_PASSWORD");
70
74
  FTP_TEST_SSL_TRUSTED_CA_CERT_FILE = System.getenv("FTP_TEST_SSL_TRUSTED_CA_CERT_FILE");
@@ -117,6 +121,7 @@ public class TestFtpFileOutputPlugin
117
121
  .set("parser", parserConfig(schemaConfig()))
118
122
  .set("type", "ftp")
119
123
  .set("host", FTP_TEST_HOST)
124
+ .set("port", FTP_TEST_PORT)
120
125
  .set("user", FTP_TEST_USER)
121
126
  .set("password", FTP_TEST_PASSWORD)
122
127
  .set("path_prefix", "my-prefix")
@@ -155,7 +160,7 @@ public class TestFtpFileOutputPlugin
155
160
  // .set("parser", parserConfig(schemaConfig()))
156
161
  // .set("type", "ftp")
157
162
  // .set("host", FTP_TEST_HOST)
158
- // .set("port", 990)
163
+ // .set("port", FTP_TEST_SSL_PORT)
159
164
  // .set("user", FTP_TEST_USER)
160
165
  // .set("password", FTP_TEST_PASSWORD)
161
166
  // .set("ssl", true)
@@ -225,6 +230,7 @@ public class TestFtpFileOutputPlugin
225
230
  .set("parser", parserConfig(schemaConfig()))
226
231
  .set("type", "ftp")
227
232
  .set("host", FTP_TEST_HOST)
233
+ .set("port", FTP_TEST_SSL_PORT)
228
234
  .set("user", FTP_TEST_USER)
229
235
  .set("password", FTP_TEST_PASSWORD)
230
236
  .set("path_prefix", FTP_TEST_PATH_PREFIX)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-ftp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- description: Stores files on FTP.
41
+ description: Store files using FTP.
42
42
  email:
43
43
  - satoshiakama@gmail.com
44
44
  executables: []
@@ -69,7 +69,7 @@ files:
69
69
  - src/test/resources/sample_02.csv
70
70
  - classpath/bcpkix-jdk15on-1.52.jar
71
71
  - classpath/bcprov-jdk15on-1.52.jar
72
- - classpath/embulk-output-ftp-0.1.1.jar
72
+ - classpath/embulk-output-ftp-0.1.2.jar
73
73
  - classpath/ftp4j-1.7.2.jar
74
74
  homepage: https://github.com/sakama/embulk-output-ftp
75
75
  licenses: