Exemplo n.º 1
0
	/** Like the other uploadByHash() function, but computes the hash.
	 *
	 * @param hashContext  The URIContext to upload the hash to (e.g. "mhash:")
	 */
	inline void uploadByHash(const URIContext &hashContext,
			const DenseDataPtr &toUpload,
			const EventListener &listener) {
		RemoteFileId rfid(
			Fingerprint::computeDigest(toUpload->data(), toUpload->length()),
			hashContext);
		uploadByHash(rfid, toUpload, listener);
	}
Exemplo n.º 2
0
	/** Uploads a filename, and if necessary, uploads the data as well.
	 *
	 * @param name         The named file to be uploaded (of the form "meerkat:///somefile.texture")
	 * @param hashContext  The location to upload the data to (usually "mhash:")
	 * @param toUpload     Data to be uploaded. Will only be uploaded if necessary.
	 * @param listener     An EventListener to receive a UploadEventPtr with the retrieved data.
	 * @param forceIfExists Upload the data even if the file already exists on all known CDN services.
	 */
	inline void upload(const URI &name,
			const URIContext &hashContext,
			const DenseDataPtr &toUpload,
			const EventListener &listener,
			bool forceIfExists) {
		RemoteFileId rfid(
			Fingerprint::computeDigest(toUpload->data(), toUpload->length()),
			hashContext);
		upload(name, rfid, toUpload, listener, forceIfExists);
	}
Exemplo n.º 3
0
	void gotNameLookup(const Callback &cb, const URI &origNamedUri, ServiceIterator *services,
			const Fingerprint &hash, const std::string &str, bool success) {
		if (!success) {
			doNameLookup(cb, origNamedUri, services, ServiceIterator::GENERAL_ERROR);
			return;
		}

		services->finished(ServiceIterator::SUCCESS);

		RemoteFileId rfid(hash, URI(origNamedUri.context(), str));
		addToCache(origNamedUri, rfid);
		cb(origNamedUri, &rfid);
	}