mirror of
https://github.com/Rogiel/httpchannel
synced 2025-12-06 07:32:50 +00:00
Implements wupload.com service
This commit is contained in:
@@ -23,6 +23,7 @@ import java.net.URI;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
|
||||
import com.rogiel.httpchannel.http.HttpContext;
|
||||
import com.rogiel.httpchannel.service.filesonic.xml.FSAPI;
|
||||
import com.rogiel.httpchannel.service.filesonic.xml.FSGetUploadURL;
|
||||
import com.rogiel.httpchannel.service.filesonic.xml.FSUpload;
|
||||
@@ -32,12 +33,14 @@ import com.rogiel.httpchannel.service.filesonic.xml.FSUpload;
|
||||
*/
|
||||
public class FileSonicAPI {
|
||||
private static final String BASE_URI = "http://api.filesonic.com/";
|
||||
|
||||
private final HttpContext ctx;
|
||||
|
||||
private String email;
|
||||
private String password;
|
||||
|
||||
public Object getInfo(int id) {
|
||||
return id;
|
||||
|
||||
public FileSonicAPI(HttpContext ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public URI getUploadURI() throws IOException {
|
||||
@@ -66,6 +69,6 @@ public class FileSonicAPI {
|
||||
throws IOException {
|
||||
final URI uri = URI.create(BASE_URI + requestURI + "&u=" + email
|
||||
+ "&p=" + password + "&format=xml");
|
||||
return JAXB.unmarshal(uri.toURL().openStream(), type);
|
||||
return JAXB.unmarshal(ctx.get(uri).asStream(), type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,17 +56,17 @@ public class FileSonicService extends AbstractHttpService implements Service,
|
||||
/**
|
||||
* This service ID
|
||||
*/
|
||||
public static final ServiceID SERVICE_ID = ServiceID.create("megaupload");
|
||||
public static final ServiceID SERVICE_ID = ServiceID.create("filesonic");
|
||||
|
||||
/**
|
||||
* The download URI pattern
|
||||
*/
|
||||
private static final Pattern DOWNLOAD_URI_PATTERN = Pattern
|
||||
.compile("http://www.filesonic.com/file/[0-9A-z]*");
|
||||
.compile("http://www\\.filesonic\\.com/file/[0-9A-z]*");
|
||||
/**
|
||||
* The FileSonic API
|
||||
*/
|
||||
private final FileSonicAPI api = new FileSonicAPI();
|
||||
private final FileSonicAPI api = new FileSonicAPI(http);
|
||||
|
||||
@Override
|
||||
public ServiceID getServiceID() {
|
||||
@@ -201,9 +201,7 @@ public class FileSonicService extends AbstractHttpService implements Service,
|
||||
|
||||
@Override
|
||||
public void logout() throws IOException {
|
||||
post("http://www.megaupload.com/?c=account").parameter("logout",
|
||||
true).request();
|
||||
// TODO check logout status
|
||||
api.logout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FSGetUploadURL extends FSResponse {
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public static class FSGetUploadURLResponse {
|
||||
@XmlElement(name = "uri")
|
||||
@XmlElement(name = "url")
|
||||
private String uploadURI;
|
||||
@XmlElement(name = "max-filesize")
|
||||
private long maxFilesize;
|
||||
|
||||
Reference in New Issue
Block a user