The default content type is set to ``application/octet-stream`` and content encoding set to ``None``.
420367
def put_content(self, content):
        

        self.blob.content_encoding = self.content_encoding
        self.blob.metadata = self.metadata
        return self.blob.upload_from_string(content, content_type=self.content_type)
1237223
public void setDefaultContentType(DefaultContentType value) {
        defaultContentType = value;
        if (defaultContentType != null) {
            setData("");
            searchable = false;
            orderable = false;
        }
    }
860501
private String getEncoding(final String contentType) {
        if (contentType == null || !contentType.contains(CHARSET)) {
            return DEFAULT_ENCODING;
        }
        String encoding = null;
        try {
            encoding = contentType.substring(contentType.indexOf(CHARSET) + CHARSET.length());
            encoding = encoding.toLowerCase().replaceAll("\"", "");
        } catch (Exception e) {
            //Extraction from the string failed.
        }
        if (!validEncodings.contains(encoding)) {
            LOGGER.warn("Invalid Encoding '{}' - using default - '{}'", encoding, DEFAULT_ENCODING);
            encoding = DEFAULT_ENCODING;
        }
        return encoding;
    }
1247231
def _guess_content_type(url):
    '''
    
    '''
    OCTET_STREAM = 'application/octet-stream'
    n = url.rfind('.')
    if n == -1:
        return OCTET_STREAM
    return mimetypes.types_map.get(url[n:].lower(), OCTET_STREAM)
375261
public Request setContent(InputStream stream, ContentType contentType) {
        entity = new InputStreamEntity(stream, contentType);
        return this;
    }
414913
protected String getContentType(Resource resource, @SuppressWarnings("unused") SlingHttpServletRequest request) {
    String mimeType = JcrBinary.getMimeType(resource);
    if (StringUtils.isEmpty(mimeType)) {
      mimeType = ContentType.OCTET_STREAM;
    }
    return mimeType;
  }
867358
def content_type(type = nil, params={})
      return response['Content-Type'] unless type
      default = params.delete :default
      mime_type = mime_type(type) || default
      fail "Unknown media type: %p" % type if mime_type.nil?
      mime_type = mime_type.dup
      unless params.include? :charset or settings.add_charset.all? { |p| not p === mime_type }
        params[:charset] = params.delete('charset') || settings.default_encoding
      end
      params.delete :charset if mime_type.include? 'charset'
      unless params.empty?
        mime_type << (mime_type.include?(';') ? ', ' : ';')
        mime_type << params.map { |kv| kv.join('=') }.join(', ')
      end
      response['Content-Type'] = mime_type
    end
455070
def _prep_binary_content(self):

		'''
		
		'''

		# nothing present
		if not self.data and not self.location and 'Content-Location' not in self.resource.headers.keys():
			raise Exception('creating/updating NonRDFSource requires content from self.binary.data, self.binary.location, or the Content-Location header')

		elif 'Content-Location' in self.resource.headers.keys():
			logger.debug('Content-Location header found, using')
			self.delivery = 'header'

		# if Content-Location is not set, look for self.data_location then self.data
		elif 'Content-Location' not in self.resource.headers.keys():

			# data_location set, trumps Content self.data
			if self.location:
				# set appropriate header
				self.resource.headers['Content-Location'] = self.location
				self.delivery = 'header'

			# data attribute is plain text, binary, or file-like object
			elif self.data:

				# if file-like object, set flag for api.http_request
				if isinstance(self.data, io.BufferedIOBase):
					logger.debug('detected file-like object')
					self.delivery = 'payload'

				# else, just bytes
				else:
					logger.debug('detected bytes')
					self.delivery = 'payload'
137158
def _parse_content_type(content_type: Optional[str]) -> Tuple[Optional[str], str]:
    
    if not content_type:
        return None, "utf-8"
    else:
        type_, parameters = cgi.parse_header(content_type)
        encoding = parameters.get("charset", "utf-8")
        return type_, encoding
207048
public void setContentEncoding(String encoding) {
        if (encoding == null) {
            _properties.remove(AMQP_PROP_CONTENT_ENCODING);
            return;
        }
        
        _properties.put(AMQP_PROP_CONTENT_ENCODING, encoding);
    }
1248044
def encoding(self):
        """"""
        encoding = None
        ct = self.get_header('content-type')
        if ct:
            ah = AcceptHeader(ct)
            if ah.media_types:
                encoding = ah.media_types[0][2].get("charset", None)

        return encoding
282139
@Override
    public String getContentType() {
	URLConnection connection = null;
	try {
	    connection = url.openConnection();
	}
	catch (IOException e) {}
	if (connection == null) return DEFAULT_CONTENT_TYPE;

	return connection.getContentType();

    }
382050
def generate_content_encoding(self):
        
        if self._definition['contentEncoding'] == 'base64':
            with self.l('if isinstance({variable}, str):'):
                with self.l('try:'):
                    self.l('import base64')
                    self.l('{variable} = base64.b64decode({variable})')
                with self.l('except Exception:'):
                    self.l('raise JsonSchemaException("{name} must be encoded by base64")')
                with self.l('if {variable} == "":'):
                    self.l('raise JsonSchemaException("contentEncoding must be base64")')
325378
def set_content(self, value: RequestContent, *,
                    content_type: str = None):
        '''
        
        '''
        assert self._attached_files is None, \
               'cannot set content because you already attached files.'
        guessed_content_type = 'application/octet-stream'
        if value is None:
            guessed_content_type = 'text/plain'
            self._content = b''
        elif isinstance(value, str):
            guessed_content_type = 'text/plain'
            self._content = value.encode('utf-8')
        else:
            guessed_content_type = 'application/octet-stream'
            self._content = value
        self.content_type = (content_type if content_type is not None
                             else guessed_content_type)
255396
def get_content_type (headers):
    
    ptype = headers.get('Content-Type', 'application/octet-stream')
    if ";" in ptype:
        # split off not needed extension info
        ptype = ptype.split(';')[0]
    return ptype.strip().lower()
14735
private static void checkContentType(String contentType, String accept, String ext, boolean strict) throws PageException {

	if (!StringUtil.isEmpty(ext, true)) {
	    ext = ext.trim().toLowerCase();
	    if (ext.startsWith("*.")) ext = ext.substring(2);
	    if (ext.startsWith(".")) ext = ext.substring(1);

		String blacklistedTypes = SystemUtil.getSystemPropOrEnvVar(
				SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST, SystemUtil.DEFAULT_UPLOAD_EXT_BLACKLIST
		).toLowerCase();
		Array blacklist = ListUtil.listToArrayRemoveEmpty(blacklistedTypes, ',');

		for (int i=blacklist.size(); i > 0; i--) {
			if (ext.equals(Caster.toString(blacklist.getE(i)).trim())){
				throw new ApplicationException("Upload of files with extension [" + ext + "] is not permitted.  "
						+ "You can configure the "
						+ SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST
						+ " System property or the "
						+ SystemUtil.convertSystemPropToEnvVar(SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST)
						+ " Environment variable to allow that file type."
				);
			}
		}
	}
	else ext = null;

	if (StringUtil.isEmpty(accept, true)) return;

	MimeType mt = MimeType.getInstance(contentType), sub;

	Array whishedTypes = ListUtil.listToArrayRemoveEmpty(accept, ',');
	int len = whishedTypes.size();
	for (int i = 1; i <= len; i++) {
	    String whishedType = Caster.toString(whishedTypes.getE(i)).trim().toLowerCase();
	    if (whishedType.equals("*")) return;
	    // check mimetype
	    if (ListUtil.len(whishedType, "/", true) == 2) {
		sub = MimeType.getInstance(whishedType);
		if (mt.match(sub)) return;
	    }

	    // check extension
	    if (ext != null && !strict) {
		if (whishedType.startsWith("*.")) whishedType = whishedType.substring(2);
		if (whishedType.startsWith(".")) whishedType = whishedType.substring(1);
		if (ext.equals(whishedType)) return;
	    }
	}
	throw new ApplicationException("The MIME type of the uploaded file [" + contentType + "] was not accepted by the server.",
		"only this [" + accept + "] mime type are accepted");
    }
906973
function () {
        var mime = this.mime();

        // if there is no mime detected, there is no accurate way to render this thing
        if (!this.mime) {
            return E;
        }

        // we create the body string first from stream and then fallback to body
        return 'data:' + mime._sanitisedContentType + ';base64, ' + ((!_.isNil(this.stream) &&
            util.bufferOrArrayBufferToBase64(this.stream)) || (!_.isNil(this.body) && util.btoa(this.body)) || E);
    }