use of twitter4j.media.ImageUploadFactory in project twitter4j by yusuke.
the class ImgLyImageUpload method main.
/**
* Usage: java twitter4j.examples.media.ImgLyImageUpload [image file path] [message]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.media.ImgLyImageUpload [image file path] [message]");
System.exit(-1);
}
try {
ImageUpload upload = new ImageUploadFactory().getInstance(MediaProvider.IMG_LY);
String url;
if (args.length >= 2) {
url = upload.upload(new File(args[0]), args[1]);
} else {
url = upload.upload(new File(args[0]));
}
System.out.println("Successfully uploaded image to img.ly at " + url);
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to upload the image: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.media.ImageUploadFactory in project twitter4j by yusuke.
the class TwippleImageUpload method main.
/**
* Usage: java twitter4j.examples.media.TwippleImageUpload [image file path] [message]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.media.TwippleImageUpload [image file path] [message]");
System.exit(-1);
}
try {
ImageUpload upload = new ImageUploadFactory().getInstance(MediaProvider.TWIPPLE);
String url;
if (args.length >= 2) {
url = upload.upload(new File(args[0]), args[1]);
} else {
url = upload.upload(new File(args[0]));
}
System.out.println("Successfully uploaded image to Twipple at " + url);
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to upload the image: " + te.getMessage());
System.exit(-1);
}
}
Aggregations