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


Java Metadata类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:36,代码来源:DropboxClient.java

示例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);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:22,代码来源:DropboxV2Storage.java

示例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);
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:27,代码来源:Dropbox.java

示例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();
}
 
开发者ID:yuriytkach,项目名称:dsync-client,代码行数:26,代码来源:DropboxUtil.java

示例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;
}
 
开发者ID:spacecowboy,项目名称:NoNonsense-FilePicker,代码行数:19,代码来源:DropboxFilePickerActivity.java

示例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);
    }
}
 
开发者ID:spacecowboy,项目名称:NoNonsense-FilePicker,代码行数:14,代码来源:DropboxFilePickerFragment.java

示例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);
    }

}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:15,代码来源:DropboxV2Storage.java

示例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 "";
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:12,代码来源:DropboxV2Storage.java

示例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);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:36,代码来源:DropboxSearchFeature.java

示例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);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:12,代码来源:DropboxListService.java

示例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);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:11,代码来源:DropboxAttributesFinderFeature.java

示例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;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:10,代码来源:DropboxAttributesFinderFeature.java

示例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;


    }
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:35,代码来源:DbxAPIOp.java

示例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);
}
 
开发者ID:boly38,项目名称:mongodbdump-java-wrapper,代码行数:13,代码来源:DropboxServiceITest.java

示例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());
}
 
开发者ID:zeldan,项目名称:dropbox-webhooks-spring-boot-example,代码行数:11,代码来源:DropboxService.java


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