@@ -0,0 +1,2036 @@
+package foam.blob;%0A%0Aimport foam.core.X;%0Aimport java.net.URL;%0Aimport java.net.HttpURLConnection;%0Aimport java.nio.ByteBuffer;%0A%0Apublic class RestBlobService%0A    extends AbstractBlobService%0A%7B%0A  public static final int BUFFER_SIZE = 8192;%0A%0A  protected String address_;%0A%0A  public RestBlobService(String address) %7B%0A    this.address_ = address + %22/httpBlobService%22;%0A  %7D%0A%0A  public String getAddress() %7B%0A    return address_;%0A  %7D%0A%0A  //update file to url%0A  @Override%0A  public Blob put_(X x, Blob blob) %7B%0A    if ( blob instanceof IdentifiedBlob ) %7B%0A      return blob;%0A    %7D%0A%0A    try %7B%0A      URL url = new URL(address_);%0A      HttpURLConnection connection = (HttpURLConnection) url.openConnetion();%0A      %0A      //create http connection%0A      connection.setConnectTimeout(5 * 1000);%0A      connection.setReadTimeout(15 * 1000);%0A      connnection.setDoOutput(true);%0A      connection.setUseCaches(false);%0A%0A      connection.setRequestMethod(%22PUT%22);%0A%0A      connection.setRequestProperty(%22Accept%22, %22*/*%22);%0A      connection.setRequestProperty(%22Connection%22, %22keep-alive%22);%0A%0A      //output blob into connection%0A      long chunk = 0;%0A      long size = blob.getSize();%0A      long chunks = (long) Math.ceil((double) size / (double) BUFFER_SIZE);%0A      Buffer buffer = new Buffer(BUFFER_SIZE, ByteBuffer.allocate(BUFFER_SIZE));%0A%0A      //generate file name%0A      while ( chunk %3C chunks ) %7B%0A        buffer = blob.read(buffer, chunkOffset(chunk));%0A        byte%5B%5D buf = buffer.getData().array();%0A%0A        //output to http outputStream%0A%0A        buffer.getData().clear();%0A        chunk++;%0A      %7D%0A%0A      return null;%0A    %7D catch ( Throwable e) %7B%0A      e.printStackTrace();%0A      return null;%0A    %7D%0A  %7D%0A%0A  //retrive file from url%0A  @Override%0A  public Blob find_(X x, Object id) %7B%0A    return null;%0A  %7D%0A%0A  @Override%0A  public String urlFor_(X x, Blob blob) %7B%0A    if ( ! (blob instanceof IdentifiedBlob) ) %7B%0A      return null;%0A    %7D%0A    return this.address_ + %22/%22 + ((IdentifiedBlob) blob).getId();%0A  %7D%0A%0A  private long chunkOffset(long i) %7B%0A    return i * BUFFER_SIZE;%0A  %7D%0A%7D

implement put_()