package hh.dejsem.net;

import hh.dejsem.K;
import hh.dejsem.SendUriNG;
import hh.dejsem.fm.NetTaskRef;
import hh.lib.D;

/**
 * expose to HTTP on server
 * ● copy file asynchronously to dejsem server
 * ● get path segment of URL from server and share it
 */
public class ExposeFile extends ServerCopy {

	String uriPath;

	public ExposeFile(D d, NetTaskRef netTaskRef) throws Exception  {
		super(d, netTaskRef);
	}

	@Override
	protected Void doInBackground(Void... params) {
		super.doInBackground();
//		String fn = args.getString(K.FILES_FROM_KEY);
		if(netTaskRef.go)
			try { uriPath = netConn.pushFileExpose(); }
			catch(Exception e) { if(!K.End.class.isInstance(e)) abend("", e); }
		return null;
	}

	@Override
	void completePostExecute() { SendUriNG.decideSendUri(uriPath); }
}
