All Downloads are FREE. Search and download functionalities are using the official Maven repository.

panda.ex.wordpress.MediaFile Maven / Gradle / Ivy

Go to download

Panda Tube is a Web Service API client for WordPress XML-RPC, Google Vision API, etc.

The newest version!
package panda.ex.wordpress;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import panda.bind.json.Jsons;
import panda.io.MimeTypes;
import panda.io.Streams;

public class MediaFile {
	public String name;
	
	public String type;

	public byte[] bits;

	public Boolean overwrite;
	
	public String post_id;

	public static MediaFile fromFile(File file) throws FileNotFoundException, IOException {
		MediaFile mf = new MediaFile();
		
		mf.name = file.getName();
		mf.bits = Streams.toByteArray(file);
		mf.type = MimeTypes.getMimeType(file.getName());
		
		return mf;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		return Jsons.toJson(this, true);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy