本文整理汇总了Java中com.dropbox.core.v2.files.Metadata类的典型用法代码示例。如果您正苦于以下问题:Java Metadata类的具体用法?Java Metadata怎么用?Java Metadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Metadata类属于com.dropbox.core.v2.files包,在下文中一共展示了Metadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: download
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
/**
* Download file from Dropbox and store it to a local file.
*/
public VersionedRook download(Uri repoUri, Uri uri, File localFile) throws IOException {
linkedOrThrow();
OutputStream out = new BufferedOutputStream(new FileOutputStream(localFile));
try {
Metadata pathMetadata = dbxClient.files().getMetadata(uri.getPath());
if (pathMetadata instanceof FileMetadata) {
FileMetadata metadata = (FileMetadata) pathMetadata;
String rev = metadata.getRev();
long mtime = metadata.getServerModified().getTime();
dbxClient.files().download(metadata.getPathLower(), rev).download(out);
return new VersionedRook(repoUri, uri, rev, mtime);
} else {
throw new IOException("Failed downloading Dropbox file " + uri + ": Not a file");
}
} catch (DbxException e) {
if (e.getMessage() != null) {
throw new IOException("Failed downloading Dropbox file " + uri + ": " + e.getMessage());
} else {
throw new IOException("Failed downloading Dropbox file " + uri + ": " + e.toString());
}
} finally {
out.close();
}
}
示例2: getFileEntry
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
@Override
public FileEntry getFileEntry(String filename) throws Exception {
try
{
filename = removeProtocol(filename);
Log.d("KP2AJ", "getFileEntry(), " +filename);
//querying root is not supported
if ((filename.equals("")) || (filename.equals("/")))
return getRootFileEntry();
if (filename.endsWith("/"))
filename = filename.substring(0,filename.length()-1);
Metadata dbEntry = dbxClient.files().getMetadata(filename);
return convertToFileEntry(dbEntry);
} catch (DbxException e) {
throw convertException(e);
}
}
示例3: listFiles
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
public List<String> listFiles() throws Exception {
if (authSession()) {
try {
List<String> files = new ArrayList<String>();
ListFolderResult listFolderResult = dropboxClient.files().listFolder("");
for (Metadata metadata : listFolderResult.getEntries()) {
String name = metadata.getName();
if (name.endsWith(".backup")) {
files.add(name);
}
}
Collections.sort(files, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s2.compareTo(s1);
}
});
return files;
} catch (Exception e) {
Log.e("Financisto", "Dropbox: Something wrong", e);
throw new ImportExportException(R.string.dropbox_error, e);
}
} else {
throw new ImportExportException(R.string.dropbox_auth_error);
}
}
示例4: convertMetadata
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
public static DropboxFileData convertMetadata(final Metadata metadata) {
final DropboxFileData.DropboxFileDataBuilder builder = DropboxFileData.builder()
.changeType(DropboxChangeType.fromMetadata(metadata))
.pathDisplay(metadata.getPathDisplay())
.pathLower(metadata.getPathLower());
if (metadata instanceof FolderMetadata) {
final FolderMetadata folderMetadata = (FolderMetadata) metadata;
builder.id(folderMetadata.getId());
} else if (metadata instanceof FileMetadata) {
final FileMetadata fileMetadata = (FileMetadata) metadata;
final ZoneId zoneId = ZoneOffset.UTC;
final Instant clientModifiedInstant = fileMetadata.getClientModified().toInstant();
final Instant serverModifiedInstant = fileMetadata.getServerModified().toInstant();
builder
.id(fileMetadata.getId())
.rev(fileMetadata.getRev())
.size(fileMetadata.getSize())
.clientModified(LocalDateTime.ofInstant(clientModifiedInstant, zoneId))
.serverModified(LocalDateTime.ofInstant(serverModifiedInstant, zoneId));
}
return builder.build();
}
示例5: getFragment
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
@Override
protected AbstractFilePickerFragment<Metadata> getFragment(@Nullable final String startPath,
final int mode, final boolean allowMultiple,
final boolean allowCreateDir, final boolean allowExistingFile,
final boolean singleClick) {
DropboxFilePickerFragment fragment = null;
if (!dropboxHelper.authenticationFailed(this)) {
DbxClientV2 dropboxClient = dropboxHelper.getClient(this);
if (dropboxClient != null) {
fragment = new DropboxFilePickerFragment(dropboxClient);
fragment.setArgs(startPath, mode, allowMultiple, allowCreateDir, allowExistingFile, singleClick);
}
}
return fragment;
}
示例6: refresh
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
/**
* If we are loading, then hide the list and show the progress bar instead.
*
* @param nextPath path to list files for
*/
@Override
protected void refresh(@NonNull Metadata nextPath) {
super.refresh(nextPath);
if (isLoading) {
progressBar.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.INVISIBLE);
}
}
示例7: checkForFileChangeFast
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
public boolean checkForFileChangeFast(String path, String previousFileVersion) throws Exception
{
if ((previousFileVersion == null) || (previousFileVersion.equals("")))
return false;
path = removeProtocol(path);
try {
Metadata entry = dbxClient.files().getMetadata(path);
return !String.valueOf(entry.hashCode()) .equals(previousFileVersion);
} catch (DbxException e) {
throw convertException(e);
}
}
示例8: getCurrentFileVersionFast
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
public String getCurrentFileVersionFast(String path)
{
try {
path = removeProtocol(path);
Metadata entry = dbxClient.files().getMetadata(path);
return String.valueOf(entry.hashCode());
} catch (DbxException e) {
Log.d(TAG, e.toString());
return "";
}
}
示例9: search
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
@Override
public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException {
try {
final AttributedList<Path> list = new AttributedList<>();
long start = 0;
SearchResult result;
do {
result = new DbxUserFilesRequests(session.getClient()).searchBuilder(workdir.isRoot() ? StringUtils.EMPTY : workdir.getAbsolute(), regex.toPattern().pattern())
.withMode(SearchMode.FILENAME).withStart(start).start();
final List<SearchMatch> matches = result.getMatches();
for(SearchMatch match : matches) {
final Metadata metadata = match.getMetadata();
final EnumSet<AbstractPath.Type> type;
if(metadata instanceof FileMetadata) {
type = EnumSet.of(Path.Type.file);
}
else if(metadata instanceof FolderMetadata) {
type = EnumSet.of(Path.Type.directory);
}
else {
log.warn(String.format("Skip file %s", metadata));
return null;
}
list.add(new Path(metadata.getPathDisplay(), type, attributes.convert(metadata)));
listener.chunk(workdir, list);
}
start = result.getStart();
}
while(result.getMore());
return list;
}
catch(DbxException e) {
throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, workdir);
}
}
示例10: parse
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
private void parse(final Path directory, final ListProgressListener listener, final AttributedList<Path> children, final ListFolderResult result)
throws ConnectionCanceledException {
for(Metadata md : result.getEntries()) {
final Path child = this.parse(directory, md);
if(child == null) {
continue;
}
children.add(child);
listener.chunk(directory, children);
}
}
示例11: find
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
@Override
public PathAttributes find(final Path file) throws BackgroundException {
try {
final Metadata metadata = new DbxUserFilesRequests(session.getClient()).getMetadata(file.getAbsolute());
return this.convert(metadata);
}
catch(DbxException e) {
throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, file);
}
}
示例12: convert
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
protected PathAttributes convert(final Metadata metadata) {
final PathAttributes attributes = new PathAttributes();
if(metadata instanceof FileMetadata) {
final FileMetadata fm = (FileMetadata) metadata;
attributes.setSize(fm.getSize());
attributes.setModificationDate(fm.getClientModified().getTime());
}
return attributes;
}
示例13: dropboxGetFiles
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
public static List<String> dropboxGetFiles(String code) {
DbxRequestConfig config = new DbxRequestConfig("Media Information Service Configuration");
DbxClientV2 client = new DbxClientV2(config, code);
ListFolderResult result = null;
List<String> elements = new LinkedList<String>();
try {
result = client.files().listFolderBuilder("/media").withRecursive(true).start();
while (true) {
for (Metadata metadata : result.getEntries()) {
if (metadata instanceof FileMetadata) {
elements.add(metadata.getName());
}
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
//System.out.println(elements.toString());
} catch (DbxException e) {
e.printStackTrace();
}
return elements;
}
示例14: should_list_directory
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
private void should_list_directory(String dirName, int dirFileMinCount) throws ListFolderErrorException, DbxException {
// GIVEN
DropboxServiceImpl dboxSvc = assumeDroptboxRequirement();
// WHEN
List<Metadata> listFolder = dboxSvc.listFolder(dirName);
// THEN
Assertions.assertThat(listFolder).isNotNull();
for (Metadata m : listFolder) {
log.info(m.getPathLower());
}
Assertions.assertThat(listFolder.size()).isGreaterThanOrEqualTo(dirFileMinCount);
}
示例15: logChangedFilesOfUser
import com.dropbox.core.v2.files.Metadata; //导入依赖的package包/类
private void logChangedFilesOfUser(final String userId, final ListFolderResult listFolderContinue) {
boolean hasMore = true;
while (hasMore) {
for (final Metadata md : listFolderContinue.getEntries()) {
LOG.info("Changed metadata: '{}'", md);
}
hasMore = listFolderContinue.getHasMore();
}
userTokenRepository.setValue(CURSORS_HASH_KEY, userId, listFolderContinue.getCursor());
}