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


Java DbxWriteMode类代码示例

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


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

示例1: putSingleFile

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private DbxEntry.File putSingleFile(File inputFile, String dropboxPath, DropboxUploadMode mode) throws Exception {
    FileInputStream inputStream = new FileInputStream(inputFile);
    DbxEntry.File uploadedFile = null;
    try {
        DbxWriteMode uploadMode = null;
        if (mode == DropboxUploadMode.force) {
            uploadMode = DbxWriteMode.force();
        } else {
            uploadMode = DbxWriteMode.add();
        }
        uploadedFile =
            DropboxAPIFacade.client.uploadFile(dropboxPath,
                        uploadMode, inputFile.length(), inputStream);
        return uploadedFile;
    } finally {
        inputStream.close();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:DropboxAPIFacade.java

示例2: upload

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public String upload(File fileToUpload) throws UploadException {
    DbxRequestConfig dconfig = new DbxRequestConfig("sc-java", Locale
            .getDefault().toString());
    DbxClient client = new DbxClient(dconfig, config.getDropboxConfig()
            .getAccessToken());

    DbxEntry.File uploadedFile = null;
    String shareLink = null;
    try (InputStream inputStream = new FileInputStream(fileToUpload);) {
        uploadedFile = client.uploadFile("/" + fileToUpload.getName(),
                DbxWriteMode.add(), fileToUpload.length(), inputStream);
        shareLink = client.createShareableUrl(uploadedFile.path);

    } catch (DbxException | IOException e) {
        throw new UploadException(e);
    }
    return shareLink;
}
 
开发者ID:mba811,项目名称:loli.io,代码行数:19,代码来源:DropboxAPI.java

示例3: subirArchivo

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
/**
 * Permite subir el fichero de log a una cuenta de Dropbox
 * @throws DbxException
 * @throws IOException
 */

public void subirArchivo() throws DbxException, IOException{
       DbxRequestConfig config = new DbxRequestConfig(
               "JavaTutorial/1.0", Locale.getDefault().toString());
       
       String accessToken = "cGF10uurG7MAAAAAAAAFGGi0UJD9H-TpMKBgESMHV5kDy5jTeF7ou8It1HY8ZFC7";
       
       DbxClient client = new DbxClient(config, accessToken);
       System.out.println("Linked account: " + client.getAccountInfo().displayName);

       FileInputStream inputStream = new FileInputStream(archivoLog);
       try {
           DbxEntry.File uploadedFile = client.uploadFile(
           		"/ArchivoLog_ " + TheHouseOfCrimes.getUsuario() + "_" + TheHouseOfCrimes.getFecha(),
               DbxWriteMode.add(), archivoLog.length(), inputStream);
           System.out.println("Uploaded: " + uploadedFile.toString());
       } finally {
           inputStream.close();
       }
}
 
开发者ID:Gandio,项目名称:ProjectRiddle,代码行数:26,代码来源:ArchivoLog.java

示例4: call

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
protected final void call(final DbxClient client, final ProgressMonitor pm) throws IOException, DbxException {
    final long fileLength = file.length();
    Uploader uploader = null;
    pm.begin(fileLength);
    final DbxWriteMode writeMode = overwrite ? DbxWriteMode.force() : DbxWriteMode.update(parent_rev);
    try (InputStream in = new FileInputStream(file)) {
        uploader = client.startUploadFile(path, writeMode, fileLength);
        final OutputStream body = uploader.getBody();
        final byte[] buffer = new byte[bufferSize];
        int read = 0;
        while ((read = in.read(buffer)) > -1) {
            body.write(buffer, 0, read);
            pm.worked(read);
        }
        uploader.finish();
    } finally {
        close(uploader);
    }
}
 
开发者ID:timezra,项目名称:dropbox-maven-plugin,代码行数:21,代码来源:FilesPut.java

示例5: uploadFile

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private void uploadFile(DbxClient client, String dropboxPath, boolean overwrite) throws DbxException, IOException {
	File file = new File(contentDir + File.separator + dropboxPath);
       FileInputStream inputStream = new FileInputStream(file);
       try {
       	DbxWriteMode mode = overwrite ? DbxWriteMode.force() : DbxWriteMode.add();
           DbxEntry.File uploadedFile = 
           	client.uploadFile(dropboxPath, mode, file.length(), inputStream);
		logger.debug("successfully uploaded file '{}'. New revision is '{}'", uploadedFile.toString(), uploadedFile.rev);
       } finally {
           inputStream.close();
       }
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:13,代码来源:DropboxSynchronizer.java

示例6: finalizeUpload

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
public void finalizeUpload(MultiPartUpload mpu) {
    try {
        String path = (String) mpu.getObject("path");
        String id = (String) mpu.getObject("id");
        dbClient.chunkedUploadFinish(path, DbxWriteMode.add(), id);
    } catch (DbxException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:11,代码来源:DropboxClient.java

示例7: upload_stream

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public static DbxEntry.File upload_stream(InputStream in, long size, String dest, DbxClient client) throws DbxException, IOException {
	if(client == null)
		throw new DbxException("Client not connected.");
	
	DbxEntry.File outfile = null;
	DbxClient.Uploader uploader = client.startUploadFile(dest, DbxWriteMode.force(), size);
       try {
       	byte[] buffer = new byte[4096];
       	int bytes_read = -1;
       	int total_read = 0;
       	int amount_to_write = 0;
       	while((bytes_read = in.read(buffer, 0, 4096)) != -1)
       	{
       		amount_to_write = bytes_read;
       		if(bytes_read + total_read > size)
       			amount_to_write = total_read - bytes_read;
       		uploader.getBody().write(buffer, 0, amount_to_write);
       		total_read += bytes_read;
       		if(total_read > size)
       			break;
       	}
   		outfile = uploader.finish();
       } finally {
           uploader.close();
       }
       return outfile;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:28,代码来源:FileUtils.java

示例8: uploadFile

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
private void uploadFile(DbxClient client, String dropboxPath, boolean overwrite) throws DbxException, IOException {
    File file = new File(contentDir + File.separator + dropboxPath);
    FileInputStream inputStream = new FileInputStream(file);
    try {
        DbxWriteMode mode = overwrite ? DbxWriteMode.force() : DbxWriteMode.add();
        DbxEntry.File uploadedFile = client.uploadFile(dropboxPath, mode, file.length(), inputStream);
        logger.debug("Successfully uploaded file '{}'. New revision is '{}'.", uploadedFile, uploadedFile.rev);
    } finally {
        inputStream.close();
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:12,代码来源:DropboxSynchronizer.java

示例9: uploadDocument

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public void uploadDocument(DbxClient client, File inputFile, String outputFile) throws Exception {
	FileInputStream inputStream = new FileInputStream(inputFile);
	try {
		DbxEntry.File uploadedFile = client.uploadFile(outputFile, DbxWriteMode.add(), inputFile.length(), inputStream);
		log(" - Uploaded: " + uploadedFile.toString());
	} finally {
		inputStream.close();
	}
}
 
开发者ID:bchevallereau,项目名称:ephesoft-extension,代码行数:10,代码来源:DropboxHelper.java

示例10: getOutputStream

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
public OutputStream getOutputStream(URI uri) throws PluginException {
    DbxClient.Uploader uploader = client.startUploadFileChunked(uri.getPath(), DbxWriteMode.force(), -1);
    return new DropboxOutputStream(uploader);
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:6,代码来源:Plugin.java

示例11: upload

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
public File upload(final long length, final InputStream is, final String fileName) throws DbxException, IOException {
    final String path = this.endpoint.getPath();
    return client.uploadFile(path + "/" + fileName, DbxWriteMode.add(), length, is);
}
 
开发者ID:dritter-hd,项目名称:camel-dropbox,代码行数:5,代码来源:DropboxOperationImpl.java

示例12: call

import com.dropbox.core.DbxWriteMode; //导入依赖的package包/类
@Override
protected final void call(final DbxClient client, final ProgressMonitor pm) throws IOException, DbxException {
    pm.begin(1);
    final DbxWriteMode writeMode = overwrite ? DbxWriteMode.force() : DbxWriteMode.update(parent_rev);
    client.chunkedUploadFinish(path, writeMode, upload_id);
}
 
开发者ID:timezra,项目名称:dropbox-maven-plugin,代码行数:7,代码来源:CommitChunkedUpload.java


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