Skip to content

Instantly share code, notes, and snippets.

@muhang
Created June 19, 2019 22:48
Show Gist options
  • Save muhang/b00b85dd65bb009bddd5a9a17998cf0b to your computer and use it in GitHub Desktop.
Save muhang/b00b85dd65bb009bddd5a9a17998cf0b to your computer and use it in GitHub Desktop.
import com.bouncex.ingestion.Product;
import org.apache.beam.sdk.io.FileSystems;
import org.apache.beam.sdk.io.fs.ResourceId;
import org.apache.commons.compress.utils.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.nio.channels.Channels;
class Scratch {
public static void main(String[] args) throws IOException {
Product product = new Product();
InputStream in = new URL(product.getImageURL()).openStream();
ResourceId rid = FileSystems.matchNewResource(product.getSku(), false);
OutputStream out = Channels.newOutputStream(FileSystems.create(rid, ""));
IOUtils.copy(in, out);
in.close();
out.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment