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


Java DbxEntry类代码示例

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


DbxEntry类属于com.dropbox.core包,在下文中一共展示了DbxEntry类的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: isFolder

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
@Override
public boolean isFolder(String child) throws IOException {
    boolean isfolder = false;

    try {
        DbxEntry entry = this.dbClient.getMetadata(child);

        if (entry.isFolder()) {
            isfolder = true;
        }
    } catch (DbxException ex) {
        throw new IOException("Error in folder checking");
    }

    return isfolder;
}
 
开发者ID:modcs,项目名称:caboclo,代码行数:17,代码来源:DropboxClient.java

示例3: isLocked

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
@Override
public synchronized boolean isLocked(String path) throws CSPApiException {
	try {
		DbxEntry lockFile = client.getMetadata(path
				+ DropboxConstants.LOCK_SUFFIX);
		DbxEntry tempLockFile = client.getMetadata(path
				+ DropboxConstants.TEMP_LOCK_SUFFIX);
		if (lockFile != null) {
			return true;
		} else if (tempLockFile != null) {
			if (new Date().compareTo(tempLockFile.asFile().lastModified) < DropboxConstants.TEMP_LOCK_DURATION) {
				return true;
			} else {
				releaseTemporaryLock(path);
				return false;
			}
		} else {
			return false;
		}
	} catch (DbxException e) {
		throw new CSPApiException(e);
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:24,代码来源:DropboxAPIIntegration.java

示例4: 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

示例5: 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

示例6: getDbxTexEntries

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
/**
 * @return List with user's files or empty List if error occurs
 */
public List<DbxEntryDto> getDbxTexEntries(DbxClient client) {
    List<DbxEntryDto> dbxEntries = new ArrayList<>();

    if (client == null) {
        return dbxEntries;
    }

    try {
        for (DbxEntry entry : client.searchFileAndFolderNames("/", TEX_EXTENSION)) {
            dbxEntries.add(new DbxEntryDto(entry));
        }
    } catch (DbxException ex) {
        DbxUtil.showDbxAccessDeniedPrompt();
        dbxEntries = new ArrayList<>(); //Empty list
    } finally {
        return dbxEntries;
    }
}
 
开发者ID:sebbrudzinski,项目名称:Open-LaTeX-Studio,代码行数:22,代码来源:DbxFileActions.java

示例7: listFiles

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
@Override
public URI[] listFiles(URI uri) {
    DbxEntry.WithChildren dirents = null;
    try {
	dirents = client.getMetadataWithChildren(clean_path(uri));
    } catch(DbxException de) {
	return null;
    }

    if(dirents == null || dirents.children.size() == 0)
	return new URI[]{};
    
    URI[] retval = new URI[dirents.children.size()];
    Iterator<DbxEntry> dirent = dirents.children.iterator();
    int idx = 0;
    while(dirent.hasNext()) {
	DbxEntry entry = dirent.next();
	try {
	    retval[idx++] = new URI("dbx:" + entry.path);
	} catch(URISyntaxException urise) {
	    return null;
	}
    }
    return retval;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:26,代码来源:Plugin.java

示例8: ls

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
public static DbxEntry[] ls(String query, DbxClient client) throws DbxException {
	DbxEntry.WithChildren listing = client.getMetadataWithChildren(query);
       if(listing == null) {
       	return new DbxEntry[]{};
       }
	if(listing.entry.isFile()) {
       	return new DbxEntry[]{listing.entry};
       }
	
	DbxEntry[] dirents = new DbxEntry[listing.children.size()];
	int idx = 0;
	for (DbxEntry child : listing.children) {
           dirents[idx++] = child;
       }
	return dirents;
}
 
开发者ID:kd0kfo,项目名称:dropboxconnector,代码行数:17,代码来源:FileUtils.java

示例9: getConsumerSearch

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
private DropboxConsumerOperation getConsumerSearch() {
    return new DropboxConsumerOperation() {
        @Override
        public List<Exchange> execute() throws DbxException {
            final List<Exchange> exchanges = new ArrayList<Exchange>();

            final Exchange exchange = endpoint.createExchange();
            final List<DbxEntry> listOfFilesFolders = client.searchFileAndFolderNames(endpoint.getPath(), endpoint.getQuery());
            exchange.getIn().setHeader("searchResult", "List<DbxEntry>");
            exchange.getIn().setBody(listOfFilesFolders);

            exchanges.add(exchange);
            return exchanges;
        }
    };
}
 
开发者ID:dritter-hd,项目名称:camel-dropbox,代码行数:17,代码来源:DropboxOperationImpl.java

示例10: getProducerGet

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
private DropboxProducerOperation getProducerGet() {
    return new DropboxProducerOperation() {
        @Override
        public void execute(final Exchange exchange) throws DbxException, IOException {
            final List<DbxEntry> body = (List<DbxEntry>) exchange.getIn().getBody();

            String path = null;
            if (body != null) {
                final DbxEntry dbxEntry = body.get(0);
                endpoint.setPath(dbxEntry.path);
                path = dbxEntry.path;
            } else {
                path = endpoint.getPath();
            }
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            client.getFile(path, null, baos);
            
            final String[] pathArray = path.split("/");
            exchange.getIn().setHeader(Exchange.FILE_NAME, pathArray[pathArray.length - 1]);
            exchange.getIn().setBody(baos);
        }
    };
}
 
开发者ID:dritter-hd,项目名称:camel-dropbox,代码行数:24,代码来源:DropboxOperationImpl.java

示例11: listFilesAndDirectories

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
@Override
public FileInstanceAbstract[] listFilesAndDirectories() throws URISyntaxException, IOException {
	try {
		DbxClient dbxClient = connect();
		DbxEntry.WithChildren entries;
		entries = dbxClient.getMetadataWithChildren(getPath());
		if (entries == null || entries.children == null)
			return null;
		FileInstanceAbstract[] fileInstances = new FileInstanceAbstract[entries.children.size()];
		int i = 0;
		for (DbxEntry entry : entries.children)
			fileInstances[i++] = new DropboxFileInstance(filePathItem, this, entry);
		return fileInstances;
	} catch (DbxException e) {
		throw new IOException(e);
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:18,代码来源:DropboxFileInstance.java

示例12: importFilesFromDropbox

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
private void importFilesFromDropbox(DbxEntry entry, String bcIdentifier, DbxClient client) throws Exception {
	String fileName = entry.name;
	if (null != fileName) {
		int indexOfDot = fileName.indexOf('.');
		if (-1 != indexOfDot) {
			BatchClass batchClass = batchClassService.getBatchClassByIdentifier(bcIdentifier);

			if (batchClass != null) {
				String uncFolder = batchClassService.getBatchClassByIdentifier(bcIdentifier).getUncFolder();
				String destinationFolder = EphesoftStringUtil.concatenate(new Object[] { uncFolder, File.separator, fileName.substring(0, indexOfDot), Character.valueOf('_'),
						Long.valueOf(System.currentTimeMillis()) });
				String destinationFile = EphesoftStringUtil.concatenate(new String[] { destinationFolder, File.separator, fileName });

				File folder = new File(destinationFolder);
				if (!folder.exists())
					folder.mkdir();

				FileOutputStream outputStream = new FileOutputStream(destinationFile);
				client.getFile(entry.path, null, outputStream);
			} else
				LOGGER.debug(bcIdentifier + " doesn't exist.");
		}
	}
}
 
开发者ID:bchevallereau,项目名称:ephesoft-extension,代码行数:25,代码来源:DropboxImporter.java

示例13: call

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
@Override
protected final void call(final DbxClient client, final ProgressMonitor pm) throws DbxException {
    final Iterable<DbxEntry> entries;
    pm.begin(1);
    if (list) {
        if (hash == null) {
            entries = from(client.getMetadataWithChildren(path));
        } else {
            final Maybe<WithChildren> metadata = client.getMetadataWithChildrenIfChanged(path, hash);
            entries = metadata.isNothing() ? Collections.<DbxEntry> emptyList() : from(metadata.getJust());
        }
    } else {
        entries = singletonList(client.getMetadata(path));
    }
    for (final DbxEntry entry : entries) {
        getLog().info(entry.toString());
    }
}
 
开发者ID:timezra,项目名称:dropbox-maven-plugin,代码行数:19,代码来源:Metadata.java

示例14: populateExchange

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
/**
 * Object payload contained in Exchange
 * Exchange Header is populated with the remote paths found.
 * Exchange Body is populated with the list of DbxEntry found.
 * @param exchange
 */
@Override
public void populateExchange(Exchange exchange) {
    StringBuffer fileExtracted = new StringBuffer();
    List<DbxEntry> entries = null;
    if (resultEntries != null) {
        entries = (List<DbxEntry>) resultEntries;
        for (DbxEntry entry : entries) {
            fileExtracted.append(entry.name + "-" + entry.path + "\n");
        }
    }
    exchange.getIn().setHeader(DropboxResultHeader.FOUNDED_FILES.name(), fileExtracted.toString());
    exchange.getIn().setBody(entries);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:DropboxSearchResult.java

示例15: collectDropboxEntries

import com.dropbox.core.DbxEntry; //导入依赖的package包/类
private void collectDropboxEntries(DbxClient client, Map<String, Long> dropboxEntries, String path) throws DbxException {
	WithChildren entries = client.getMetadataWithChildren(path);
	for (DbxEntry entry : entries.children) {
		if (entry.isFolder()) {
			collectDropboxEntries(client, dropboxEntries, entry.path);
		} else {
			dropboxEntries.put(entry.path, entry.asFile().lastModified.getTime());
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:11,代码来源:DropboxSynchronizer.java


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