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


Java DbxEntry.File方法代码示例

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


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

示例1: putSingleFile

import com.dropbox.core.DbxEntry; //导入方法依赖的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.DbxEntry; //导入方法依赖的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.DbxEntry; //导入方法依赖的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: uploadFile

import com.dropbox.core.DbxEntry; //导入方法依赖的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

示例5: getFile

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public void getFile(File file, String path) throws IOException {
    try {
        FileOutputStream outputStream = new FileOutputStream(file);

        DbxEntry.File downloadedFile = dbClient.getFile(path, null,
                outputStream);

    } catch (DbxException ex) {
        throw new IOException("Error to get file");
    }
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:13,代码来源:DropboxClient.java

示例6: getRevisions

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public List<Revision> getRevisions(String path) throws CSPApiException {
	try {
		List<DbxEntry.File> revs = client.getRevisions(path);
		List<Revision> out = new ArrayList<>();
		for (DbxEntry.File f : revs) {
			Revision rev = new Revision(f.rev, f.lastModified, f.numBytes);
			out.add(rev);
		}
		return out;

	} catch (DbxException e) {
		throw new CSPApiException(e);
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:16,代码来源:DropboxAPIIntegration.java

示例7: saveStream

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public URI saveStream(InputStream input, int amount_to_write,
		URI destination) throws PluginException {
	try {
		DbxEntry.File retval = FileUtils.upload_stream(input, amount_to_write, clean_path(destination.getPath()), client);
		return new URI("dbx:" + retval.path);
   	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:12,代码来源:Plugin.java

示例8: upload_stream

import com.dropbox.core.DbxEntry; //导入方法依赖的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

示例9: upload_file

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
public static DbxEntry.File upload_file(File src, String dest, DbxClient client) throws DbxException, IOException {
	FileInputStream inputStream = new FileInputStream(src);
       DbxEntry.File outfile = null;
	try {
       	outfile = upload_stream(inputStream, src.length(), dest, client);
       } finally {
       	inputStream.close();
       }
	return outfile;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:11,代码来源:FileUtils.java

示例10: getLastModified

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public Long getLastModified() {
	if (dbxEntry == null)
		return null;
	Date dt = null;
	if (dbxEntry instanceof DbxEntry.File)
		dt = ((DbxEntry.File) dbxEntry).lastModified;
	if (dt == null)
		return null;
	return dt.getTime();
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:12,代码来源:DropboxFileInstance.java

示例11: getFileSize

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
@Override
public Long getFileSize() {
	if (dbxEntry == null)
		return null;
	if (dbxEntry instanceof DbxEntry.File)
		return ((DbxEntry.File) dbxEntry).numBytes;
	return null;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:9,代码来源:DropboxFileInstance.java

示例12: uploadFile

import com.dropbox.core.DbxEntry; //导入方法依赖的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

示例13: uploadDocument

import com.dropbox.core.DbxEntry; //导入方法依赖的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

示例14: restoreFile

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
/**
 * All this nonsense because the DbxEntry#read method returns null if an entry is deleted
 */
public DbxEntry.File restoreFile(final String path, final String rev) throws DbxException {
    DbxPath.checkArgNonRoot("path", path);
    if (rev == null) {
        throw new IllegalArgumentException("'rev' can't be null");
    }
    if (rev.length() == 0) {
        throw new IllegalArgumentException("'rev' can't be empty");
    }

    final String apiPath = "1/restore/auto" + path;
    final String[] params = { "rev", rev };

    return DbxRequestUtil.doGet(client.getRequestConfig(), client.getAccessToken(), getApi(), apiPath, params, null,
            new DbxRequestUtil.ResponseHandler<DbxEntry.File>() {
                @Override
                public DbxEntry.File handle(final HttpRequestor.Response response) throws DbxException {
                    if (response.statusCode == 404) {
                        return null;
                    }
                    if (response.statusCode != 200) {
                        throw DbxRequestUtil.unexpectedStatus(response);
                    }
                    return DbxRequestUtil.readJsonFromResponse(Reader, response.body);
                }
            });
}
 
开发者ID:timezra,项目名称:dropbox-maven-plugin,代码行数:30,代码来源:DbxClientWrapper.java

示例15: main

import com.dropbox.core.DbxEntry; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, DbxException, URISyntaxException {
   
	if(args.length == 0 || args[0].equals("help")) {
		print_usage();
		System.exit(0);
	}
	String command = args[0].toLowerCase();
	
	// Version?
	if(command.equals("version")) {
		BuildInfo info = new BuildInfo(CommandLine.class);
    	System.out.println(info.get_version());
    	System.exit(0);
	}
	
	// Sanity check before connecting.
	sanity_check(args);
	
    // Connect
	DbxClient client = Connector.connect(new APIKeyStore("appkey.properties"), System.out, System.in);

    // Report with whom we're working
    System.out.println("Linked account: " + client.getAccountInfo().displayName);

    switch(command.toLowerCase()) {
    case "ls":
    	String query = (args.length > 1) ? args[1] : "/";
    	DbxEntry[] dirents = FileUtils.ls(query, client);
     for(DbxEntry dirent : dirents) {
     	if(dirent.isFile())
     	{
     		DbxEntry.File asfile = dirent.asFile();
     		System.out.println(asfile.lastModified + "\t"
     				+ asfile.numBytes + "\t"
     				+ asfile.path);
     	}
     	else
     	{
     		DbxEntry.Folder asfolder = dirent.asFolder();
     		System.out.println(asfolder.path);
     	}
     }
    	break;
    case "mkdir":
    	FileUtils.mkdir(args[1], client);
    	break;
    case "upload":
    	File inputFile = new File(args[1]);
    	String dest = args[2];
    	if(dest.charAt(0) != '/')
    		dest = "/" + dest;
    	DbxEntry.File outfile = FileUtils.upload_file(inputFile, dest, client);
    	System.out.println("Uploaded " + outfile.numBytes + " bytes to " + outfile.name);
    	break;
    }
    
    

    /*
    FileOutputStream outputStream = new FileOutputStream("magnum-opus.txt");
    try {
        DbxEntry.File downloadedFile = client.getFile("/magnum-opus.txt", null,
			  outputStream);
        System.out.println("Metadata: " + downloadedFile.toString());
    } finally {
        outputStream.close();
    }
    /**/
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:70,代码来源:CommandLine.java


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