0

I'm using Java move a file into a dropbox folder, which if a new file or photo that gets added, will trigger an IFTTT.com recipe that will post it to twitter. I am using Apache Commons IO for the movefile method on File Utils to create a File, and then move it.

But first, I have it find a path to a Content Path folder with a contentFileArray, which creates a File that gives us the image that I want to use. Then it takes the image, and creates a File destination that is in the local Dropbox folder. I set the file name and add the file extension.

Then I move it into the dropbox folder... which then triggers an IFTTT recipe that lets you post a Tweet when a file enters the Dropbox folder... or if a photo image enters the Dropbox folder. The problem is that a .png triggers as a file and as a photo, so I double post. It activates the File recipe and the Photo recipe.

IFTTT doesn't have any documentation for how Dropbox's Triggers work on the website, but maybe I'm missing something with FileUtils.moveFile(). Maybe it creates a file at that location, then has us change the file name. This could cause it to be read twice.

 File src = new File(messageObject.getContentpath()+"\\"+contentFileArray[0]);

 String ext = "."+FilenameUtils.getExtension(contentFileArray[0]);
 File dest = new File(messageObject.getDropboxpath()+"\\"+messageObject.getMessage()+ext);
 FileUtils.moveFile(src, dest);

 successfulContentPosts++;

Does calling this line, cause this file to be made at this actual file path?

  File dest = new      File(messageObject.getDropboxpath()+"\\"+messageObject.getMessage()+ext);
Jayizzle
  • 532
  • 1
  • 6
  • 24
  • I am not familiar with IFTTT, is it possible it is trying to post the file before it finishes copying (possibly checking to see if it is a valid image before posting)? A File only holds the representation of that location on disk, no files are created on disk until you call FileUtils.moveFile(File, File) and it opens the output file stream, and that stream stays open until an exception is thrown or all data has been written. – Shadowtrot May 24 '16 at 17:55
  • That definition of how File works really helps, but when I worked on this before, it allowed for posts that would result in EITHER a file OR a photo post. The difference in it now is that I rename it was it travels with moveFile, where as before I created the file/photo in a folder,then just moved it. This could be a misunderstanding by how FileUtils works, so Ill double check the other option and get back. – Jayizzle May 24 '16 at 18:03
  • Nope, the old way doesn't seem to accept photos. It posts both a file and a photo post with one. I set up two recipes, but one should be mutually exclusive with the other. – Jayizzle May 24 '16 at 18:18

0 Answers0