1
using Kraken;
using Kraken.Http;
using Kraken.Model;
public void ResizeSelectedImages()
        {
            var filesToResize = FilesInFolderListBox.SelectedItems;
            var connection = Connection.Create(Properties.Settings.Default.krakenkey, Properties.Settings.Default.krakensecret, Properties.Settings.Default.SandBoxMode);
            var client = new Client(connection);

            foreach (var file in filesToResize)
            {
                var response = client.OptimizeWait(new Uri("http://awesome-website.com/images/header.png"),
                                new OptimizeUploadWaitRequest()
                                {
                                    ResizeImage = new ResizeImage
                                    {
                                        Width = 100,
                                        Height = 75,
                                        Strategy = Strategy.Crop
                                    }
                                }
                        );

            }
        }

我想我想做什么很明显,这几乎是刚刚从 kraken.io 文档中复制的代码。这给了我很多红线,从 "new OptimizeUploadWaitRequest()" 开始,说 "Argument 2: conversion from Kraken.Model.OptimizeUploadWaitRequest in System.Threading.CancellationToken not possible"...

到目前为止,Kraken 的其他方面都在工作(从我的本地目录中获取图像,“优化”它们并将它们上传到 FTP.. 不知何故,虽然这个不起作用......谷歌搜索都是关于某些海洋生物的至少6个武器...

有人知道这个问题并且可以帮助我吗?或者看看我做错了什么?..或指出我正确的方向..我尝试重新安装包(uri将是file.toString()但这不重要并且在我从文档中复制它之前已经给出了一个错误)

4

1 回答 1

1

好的,解决了我自己的问题..我只是接受了错误的任务..并且 kraken.io 网站上的文档有问题。

根据文档,您应该给它一个uri和optimizeUploadWaitRequest..而根据元数据,没有什么需要uri +和optimizeUploadWaitRequest ..只有uri和cancellationToken或文件路径和optimizeUploadWaitRequest..所以..是的。 .应该先看看那里。

        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeSetUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeSetUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeSetUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeSetRequest optimizeSetRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeSetRequest optimizeSetRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(IOptimizeRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeSetUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeUploadRequest optimizeRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, IOptimizeUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(byte[] image, string filename, IOptimizeUploadRequest optimizeRequest);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, Uri callbackUrl, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeResult>> Optimize(string filePath, Uri callbackUrl);
        //public Task<IApiResponse<OptimizeResult>> Optimize(Uri imageUri, Uri callbackUrl);
        //public Task<IApiResponse<OptimizeResult>> Optimize(Uri imageUri, Uri callbackUrl, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, IOptimizeUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(Uri imageUri);
        public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(Uri imageUri, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(string filePath, IOptimizeSetUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(string filePath, IOptimizeSetUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(byte[] image, string filename, IOptimizeSetUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(byte[] image, string filename, IOptimizeSetUploadWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(IOptimizeSetWaitRequest optimizeSetWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeSetWaitResults>> OptimizeWait(IOptimizeSetWaitRequest optimizeSetWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(IOptimizeWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(IOptimizeWaitRequest optimizeWaitRequest);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(byte[] image, string filename, IOptimizeUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(byte[] image, string filename, IOptimizeUploadWaitRequest optimizeWaitRequest);
        public Task<IApiResponse<OptimizeWaitResult>> OptimizeWait(string filePath, IOptimizeUploadWaitRequest optimizeWaitRequest, CancellationToken cancellationToken);
        //public Task<IApiResponse<UserResult>> UserStatus(CancellationToken cancellationToken);
        //public Task<IApiResponse<UserResult>> UserStatus();

所以我只需要从那里取出正确的一个(两个条目没有被注释掉..为了清楚起见..我希望)

所以是的.. 和 kraken 一样好用.. 文档.. 不是最新的。

于 2017-08-09T12:29:27.743 回答