dataURI to blob, ref to https://gist.github.com/fupslot/5015897
@param dataURI
355981
function dataURItoBuffer(dataURI){
    var byteString = atob(dataURI.split(',')[1]);
    var buffer = new ArrayBuffer(byteString.length);
    var view = new Uint8Array(buffer);
    for (var i = 0; i < byteString.length; i++) {
        view[i] = byteString.charCodeAt(i);
    }
    return buffer;
}
1159095
private String encodeUri( String uri ) {
    String newUri = "";
    StringTokenizer st = new StringTokenizer( uri, "/ ", true );
    while ( st.hasMoreTokens()) {
      String tok = st.nextToken();
      if ( tok.equals( "/" ))
        newUri += "/";
      else if ( tok.equals( " " ))
        newUri += "%20";
      else {
        try {
          newUri += URLEncoder.encode( tok, "UTF-8" );
        } catch( UnsupportedEncodingException e ) {
          throw  Log.errRTExcept(e);
        }
      }
    }
    return newUri;
  }
1366770
public static DataNode createFromEncoded(String encodedData, String baseUri) {
        String data = Entities.unescape(encodedData);
        return new DataNode(data);
    }
703365
public DfuServiceInitiator setZip(@NonNull final Uri uri) {
		return init(uri, null, 0, DfuBaseService.TYPE_AUTO, DfuBaseService.MIME_TYPE_ZIP);
	}
96395
public static function getResponseFromDataUri($dataUri)
    {
        $mimeType = substr($dataUri, 5, strpos($dataUri, ';') - 5);
        $content = base64_decode(substr($dataUri, strpos($dataUri, ',') + 1));

        return new Response($content, Response::HTTP_OK, [
            'Content-Type' => $mimeType,
        ]);
    }
799770
public static <E> View<E> viewForUri(Dataset<E> dataset, String uri) {
    return viewForUri(dataset, URI.create(uri));
  }
34084
public BinaryResource bytes(URI anUri, AbstractContent someContent) throws IOException {
		return doPOSTOrPUT(anUri, someContent, createBinaryResource());
	}
100529
public ConverterServerBuilder baseUri(String baseUri) {
        checkNotNull(baseUri);
        this.baseUri = URI.create(baseUri);
        return this;
    }
255233
function getDataUriFormat(dataUri) {
  if (defined(dataUri)) {
    const slashIndex = dataUri.indexOf("/");
    const commaIndex = dataUri.indexOf(",");
    // Don't look into the data itself. Assume the format is somewhere in the first 40 chars.
    if (slashIndex < commaIndex && commaIndex < 40) {
      return dataUri.slice(slashIndex + 1, commaIndex);
    }
  }
}
819874
private Optional<String> getNonRDFSourceDescribedByUri(final String resourceUri) throws IOException {
        Optional<String> nonRdfSourceDescUri = Optional.empty();
        final Header[] links = getLinkHeaders(resourceUri);
        if ( links != null ) {
            String descriptionUri = null;
            boolean isNonRDFSource = false;
            for ( final Header h : links ) {
                final FcrepoLink link = new FcrepoLink(h.getValue());
                if ( link.getRel().equals("describedby") ) {
                    descriptionUri = link.getUri().toString();
                } else if ( link.getUri().toString().contains(NON_RDF_SOURCE_URI)) {
                    isNonRDFSource = true;
                }
            }
            LOGGER.debug("isNonRDFSource: " + isNonRDFSource);
            if (isNonRDFSource && descriptionUri != null) {
                nonRdfSourceDescUri = Optional.of(descriptionUri);
            }
        }
        return nonRdfSourceDescUri;
    }
706634
function put(uri, data, locals) {
  var model = files.getLayoutModules(getLayoutName(uri)),
    callHooks = _.get(locals, 'hooks') !== 'false',
    result;

  if (model && _.isFunction(model.save) && callHooks) {
    result = models.put(model, uri, data, locals);
  } else {
    result = dbOps.putDefaultBehavior(uri, data);
  }

  return result;
}
758394
function dataURLToBlob(dataURL) {
                    var BASE64_MARKER = ';base64,',
                        contentType,
                        parts,
                        raw;
                    if (dataURL.indexOf(BASE64_MARKER) === -1) {
                        parts = dataURL.split(',');
                        contentType = parts[0].split(':')[1];
                        raw = parts[1];

                        return new Blob([raw], {type: contentType});
                    }

                    parts = dataURL.split(BASE64_MARKER);
                    contentType = parts[0].split(':')[1];
                    raw = window.atob(parts[1]);
                    var rawLength = raw.length;
                    var uInt8Array = new Uint8Array(rawLength);

                    for (var i = 0; i < rawLength; ++i) {
                        uInt8Array[i] = raw.charCodeAt(i);
                    }
                    return new Blob([uInt8Array.buffer], {type: contentType});
                }
1330947
function (mu, uriString, filename) {
        console.info('#green{[convert file]} ' + filename + ' #green{to data uri]}\n');
        return mu.replace(uriString, [
            'data:',
            mime.getType(filename),
            ';base64,',
            fs.readFileSync(filename).toString('base64')
        ].join(''));
    }
947500
function(dataUri, fileName) {

            var blob = joint.util.dataUriToBlob(dataUri);
            joint.util.downloadBlob(blob, fileName);
        }
1190896
function dataURItoBlob(dataURI) {
  // convert base64/URLEncoded data component to raw binary data held in a string
  var byteString;
  if (dataURI.split(',')[0].indexOf('base64') >= 0)
    byteString = atob(dataURI.split(',')[1]);
  else
    byteString = unescape(dataURI.split(',')[1]);

  // separate out the mime component
  var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];

  // write the bytes of the string to a typed array
  var ia = new Uint8Array(byteString.length);
  for (var i = 0; i < byteString.length; i++) {
    ia[i] = byteString.charCodeAt(i);
  }

  return new Blob([ia], {
    type: mimeString
  });
}
887921
public function buildDataUri(string $uri, array $data): Uri
    {

        // Create a query string for the URI. We automatically
        // include the datasource value from the configuration.
        $query_params = array_merge([
            'datasource' => $this->getConfiguration()->datasource,
        ], $this->getQueryString());

        return Uri::fromParts([
            'scheme' => $this->getConfiguration()->esi_scheme,
            'host'   => $this->getConfiguration()->esi_host,
            'port'   => $this->getConfiguration()->esi_port,
            'path'   => rtrim($this->getVersion(), '/') .
                $this->mapDataToUri($uri, $data),
            'query'  => http_build_query($query_params),
        ]);
    }
562603
public static String getJsonDatatypeFromDatatypeIri(String datatypeIri) {
		switch (datatypeIri) {
			case DatatypeIdValue.DT_ITEM:
				return DatatypeIdImpl.JSON_DT_ITEM;
			case DatatypeIdValue.DT_GLOBE_COORDINATES:
				return DatatypeIdImpl.JSON_DT_GLOBE_COORDINATES;
			case DatatypeIdValue.DT_URL:
				return DatatypeIdImpl.JSON_DT_URL;
			case DatatypeIdValue.DT_COMMONS_MEDIA:
				return DatatypeIdImpl.JSON_DT_COMMONS_MEDIA;
			case DatatypeIdValue.DT_TIME:
				return DatatypeIdImpl.JSON_DT_TIME;
			case DatatypeIdValue.DT_QUANTITY:
				return DatatypeIdImpl.JSON_DT_QUANTITY;
			case DatatypeIdValue.DT_STRING:
				return DatatypeIdImpl.JSON_DT_STRING;
			case DatatypeIdValue.DT_MONOLINGUAL_TEXT:
				return DatatypeIdImpl.JSON_DT_MONOLINGUAL_TEXT;
			case DatatypeIdValue.DT_PROPERTY:
				return DatatypeIdImpl.JSON_DT_PROPERTY;
			default:
				//We apply the reverse algorithm of JacksonDatatypeId::getDatatypeIriFromJsonDatatype
				Matcher matcher = DATATYPE_ID_PATTERN.matcher(datatypeIri);
				if(!matcher.matches()) {
					throw new IllegalArgumentException("Unknown datatype: " + datatypeIri);
				}
		
				StringBuilder jsonDatatypeBuilder = new StringBuilder();
				for(char ch : StringUtils.uncapitalize(matcher.group(1)).toCharArray()) {
					if(Character.isUpperCase(ch)) {
						jsonDatatypeBuilder
								.append('-')
								.append(Character.toLowerCase(ch));
					} else {
						jsonDatatypeBuilder.append(ch);
					}
				}
				return jsonDatatypeBuilder.toString();
		}
	}