当前位置: 首页>>代码示例>>Java>>正文


Java Mimetypes类代码示例

本文整理汇总了Java中org.jets3t.service.utils.Mimetypes的典型用法代码示例。如果您正苦于以下问题:Java Mimetypes类的具体用法?Java Mimetypes怎么用?Java Mimetypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Mimetypes类属于org.jets3t.service.utils包,在下文中一共展示了Mimetypes类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readFolderContents

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
private void readFolderContents(File folder)
		throws NoSuchAlgorithmException, IOException, S3ServiceException {
	Iterator filesinFolder = fileUtils.iterateFiles(folder, null, true);
	while (filesinFolder.hasNext()) {
		Object file = filesinFolder.next();
		Logger.debug("File: " + file);
		String key = "testfilnamekey";
		if (folder.isDirectory()) {
			S3Object s3Obj = new S3Object(bucket, (File) file);
			s3Obj.setKey(key);
			s3Obj.setContentType(Mimetypes.getInstance().getMimetype(
					s3Obj.getKey()));
			s3Objs.add(s3Obj);
		} else {
			Logger.warn("S3FS.readFolderContents() File: "
					+ folder.getName() + " is not a folder.");
		}
	}
}
 
开发者ID:StarterInc,项目名称:Ignite,代码行数:20,代码来源:S3FS.java

示例2: listAllBucketsImpl

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
protected S3Bucket[] listAllBucketsImpl() throws S3ServiceException {
    if (log.isDebugEnabled()) {
        log.debug("Listing all buckets for AWS user: " + getAWSCredentials().getAccessKey());
    }
    
    String bucketName = ""; // Root path of S3 service lists the user's buckets.
    HttpMethodBase httpMethod =  performRestGet(bucketName, null, null, null);
    String contentType = httpMethod.getResponseHeader("Content-Type").getValue();
        
    if (!Mimetypes.MIMETYPE_XML.equals(contentType)) {
        throw new S3ServiceException("Expected XML document response from S3 but received content type " + 
            contentType);
    }

    S3Bucket[] buckets = (new XmlResponsesSaxParser()).parseListMyBucketsResponse(
        new HttpMethodReleaseInputStream(httpMethod)).getBuckets();
    return buckets;
}
 
开发者ID:fajoy,项目名称:jets3t,代码行数:19,代码来源:RestS3Service.java

示例3: doCreateFolder

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
protected void doCreateFolder() throws Exception {
  if (!Mimetypes.MIMETYPE_JETS3T_DIRECTORY.equals(object.getContentType())) {
    object.setContentType(Mimetypes.MIMETYPE_JETS3T_DIRECTORY);

    LOG.debug(String.format("creating folder '%s'", object.getKey()));
    service.putObject(bucket, object);
  }
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:9,代码来源:Jets3tFileObject.java

示例4: doGetType

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
protected FileType doGetType() throws Exception {
  if (null == object.getContentType()) {
    return FileType.IMAGINARY;
  }

  String contentType = object.getContentType();
  if ("".equals(object.getKey()) || Mimetypes.MIMETYPE_JETS3T_DIRECTORY.equals(contentType)) {
    return FileType.FOLDER;
  }

  return FileType.FILE;
}
 
开发者ID:thinkberg,项目名称:moxo,代码行数:13,代码来源:Jets3tFileObject.java

示例5: isDirectoryPlaceholder

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public boolean isDirectoryPlaceholder() {
    // Recognize "standard" directory place-holder indications used by
    // Amazon's AWS Console and Panic's Transmit.
    if (this.getKey().endsWith("/")
        && this.getContentLength() == 0)
    {
        return true;
    }
    // Recognize s3sync.rb directory placeholders by MD5/ETag value.
    if ("d66759af42f282e1ba19144df2d405d0".equals(this.getETag()))
    {
        return true;
    }
    // Recognize place-holder objects created by the Google Storage console
    // or S3 Organizer Firefox extension.
    if (this.getKey().endsWith("_$folder$")
        && this.getContentLength() == 0)
    {
        return true;
    }
    // Recognize legacy JetS3t directory place-holder objects, only gives
    // accurate results if an object's metadata is populated.
    if (this.getContentLength() == 0
        && Mimetypes.MIMETYPE_JETS3T_DIRECTORY.equals(this.getContentType()))
    {
        return true;
    }
    return false;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:31,代码来源:StorageObject.java

示例6: isXmlContentType

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
/**
 * @param contentType
 * @return true if the given Content-Type string represents an XML document.
 */
protected boolean isXmlContentType(String contentType) {
    if (contentType != null
        && contentType.toLowerCase().startsWith(Mimetypes.MIMETYPE_XML.toLowerCase()))
    {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:14,代码来源:RestStorageService.java

示例7: createObjectImpl

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
protected Map<String, Object> createObjectImpl(String bucketName, String objectKey, String contentType,
    HttpEntity requestEntity, Map<String, Object> metadata,
    Map<String, String> requestParams, AccessControlList acl,
    String storageClass, String serverSideEncryptionAlgorithm)
    throws ServiceException
{
    if (metadata == null) {
        metadata = new HashMap<String, Object>();
    } else {
        // Use a new map object in case the one we were provided is immutable.
        metadata = new HashMap<String, Object>(metadata);
    }
    if (contentType != null) {
        metadata.put("Content-Type", contentType);
    } else {
        metadata.put("Content-Type", Mimetypes.MIMETYPE_OCTET_STREAM);
    }

    // Apply per-object or default options when uploading object
    prepareStorageClass(metadata, storageClass, true, objectKey);
    prepareServerSideEncryption(metadata, serverSideEncryptionAlgorithm, objectKey);

    boolean isExtraAclPutRequired = !prepareRESTHeaderAcl(metadata, acl);

    if (log.isDebugEnabled()) {
        log.debug("Creating object bucketName=" + bucketName +
            ", objectKey=" + objectKey +
            ", storageClass=" + storageClass + "." +
            " Content-Type=" + metadata.get("Content-Type") +
            " Including data? " + (requestEntity != null) +
            " Metadata: " + metadata +
            " ACL: " + acl
            );
    }

    HttpResponseAndByteCount methodAndByteCount = performRestPut(
        bucketName, objectKey, metadata, requestParams, requestEntity, true);

    // Consume response content.
    HttpResponse httpResponse = methodAndByteCount.getHttpResponse();

    Map<String, Object> map = new HashMap<String, Object>();
    map.putAll(metadata); // Keep existing metadata.
    map.putAll(convertHeadersToMap(httpResponse.getAllHeaders()));
    map.put(StorageObject.METADATA_HEADER_CONTENT_LENGTH, String.valueOf(methodAndByteCount.getByteCount()));
    map = ServiceUtils.cleanRestMetadataMap(
        map, this.getRestHeaderPrefix(), this.getRestMetadataPrefix());

    if (isExtraAclPutRequired) {
        if (log.isDebugEnabled()) {
            log.debug("Creating object with a non-canned ACL using REST, so an extra ACL Put is required");
        }
        putAclImpl(bucketName, objectKey, acl, null);
    }

    return map;
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:58,代码来源:RestStorageService.java

示例8: createObjectImpl

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
protected Map createObjectImpl(String bucketName, String objectKey, String contentType, 
    RequestEntity requestEntity, Map metadata, AccessControlList acl) 
    throws S3ServiceException 
{
    if (metadata == null) {
        metadata = new HashMap();
    } else {
        // Use a new map object in case the one we were provided is immutable.
        metadata = new HashMap(metadata);
    }
    if (contentType != null) {
        metadata.put("Content-Type", contentType);
    } else {
        metadata.put("Content-Type", Mimetypes.MIMETYPE_OCTET_STREAM);            
    }
    boolean putNonStandardAcl = false;
    if (acl != null) {
        if (AccessControlList.REST_CANNED_PRIVATE.equals(acl)) {
            metadata.put(Constants.REST_HEADER_PREFIX + "acl", "private");
        } else if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(acl)) { 
            metadata.put(Constants.REST_HEADER_PREFIX + "acl", "public-read");
        } else if (AccessControlList.REST_CANNED_PUBLIC_READ_WRITE.equals(acl)) { 
            metadata.put(Constants.REST_HEADER_PREFIX + "acl", "public-read-write");
        } else if (AccessControlList.REST_CANNED_AUTHENTICATED_READ.equals(acl)) {
            metadata.put(Constants.REST_HEADER_PREFIX + "acl", "authenticated-read");
        } else {
            putNonStandardAcl = true;
        }
    }
        
    if (log.isDebugEnabled()) {
        log.debug("Creating object bucketName=" + bucketName + ", objectKey=" + objectKey + "." + 
            " Content-Type=" + metadata.get("Content-Type") +
            " Including data? " + (requestEntity != null) +
            " Metadata: " + metadata +
            " ACL: " + acl
            );
    }
    
    HttpMethodAndByteCount methodAndByteCount = performRestPut(
        bucketName, objectKey, metadata, null, requestEntity, true);
        
    // Consume response content.
    HttpMethodBase httpMethod = methodAndByteCount.getHttpMethod();
        
    Map map = new HashMap();
    map.putAll(metadata); // Keep existing metadata.
    map.putAll(convertHeadersToMap(httpMethod.getResponseHeaders()));
    map.put(S3Object.METADATA_HEADER_CONTENT_LENGTH, String.valueOf(methodAndByteCount.getByteCount()));
    map = ServiceUtils.cleanRestMetadataMap(map);

    if (putNonStandardAcl) {
        if (log.isDebugEnabled()) {
            log.debug("Creating object with a non-canned ACL using REST, so an extra ACL Put is required");
        }
        putAclImpl(bucketName, objectKey, acl);
    }
    
    return map;
}
 
开发者ID:fajoy,项目名称:jets3t,代码行数:61,代码来源:RestS3Service.java

示例9: StorageObject

import org.jets3t.service.utils.Mimetypes; //导入依赖的package包/类
/**
 * Create an object representing a file. The object is initialised with the file's name
 * as its key, the file's content as its data, a content type based on the file's extension
 * (see {@link Mimetypes}), and a content length matching the file's size.
 * The file's MD5 hash value is also calculated and provided to the destination service,
 * so the service can verify that no data are corrupted in transit.
 * <p>
 * <b>NOTE:</b> The automatic calculation of a file's MD5 hash digest as performed by
 * this constructor could take some time for large files, or for many small ones.
 *
 * @param file
 * the file the object will represent. This file must exist and be readable.
 *
 * @throws IOException when an i/o error occurred reading the file
 * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm
 */
public StorageObject(File file) throws NoSuchAlgorithmException, IOException {
    this(file.getName());
    setContentLength(file.length());
    setContentType(Mimetypes.getInstance().getMimetype(file));
    if (!file.exists()) {
        throw new FileNotFoundException("Cannot read from file: " + file.getAbsolutePath());
    }
    setDataInputFile(file);
    setMd5Hash(ServiceUtils.computeMD5Hash(new FileInputStream(file)));
}
 
开发者ID:guptavishal,项目名称:jets3t-aws-roles,代码行数:27,代码来源:StorageObject.java


注:本文中的org.jets3t.service.utils.Mimetypes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。