我尝试使用jQuery Dropzone将图像上传到Imgur或任何其他域,但这不起作用.
这是我的dropzone设置:
$("div.dropzone").dropzone
success: -> console.log arguments
paramName: "image"
method: "post"
maxFilesize: 2
url: "https://api.imgur.com/3/upload"
headers:
Authorization: "Client-ID *************"
Run Code Online (Sandbox Code Playgroud)
这不起作用.它表示返回码为0.请求标头:
Host: api.imgur.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Origin: http://my.opencubes.io
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization,cache-control,x-requested-with
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Run Code Online (Sandbox Code Playgroud)
首先,你可以看到cient id没有出现:(.但是最大的问题是使用的方法是OPTIONS.响应头:

当我尝试将文件上传到我的另一个域时,我遇到了同样的问题(dropzone位于子域中)
在控制台中我看到:
Une demande multi-origines (Cross-Origin Request) a été bloquée : la politique « Same Origin » ne permet pas de consulter la ressource distante située …Run Code Online (Sandbox Code Playgroud) 简而言之,这是我的项目结构:
+ A
| + some content
|
+ B
+ A
Run Code Online (Sandbox Code Playgroud)
我希望在我的主 git 存储库中有一个B指向A. 但由于该A项目包含 main 方法,我希望能够在提交之前快速测试,因此我想要一个指向的符号链接(或者更确切地说,mklink因为我在 Windows 上)A,以便它无需提交即可更新。
我正在使用 AVA 来运行我的测试。我在根目录下使用了一个 config.js 文件,我希望它在运行测试单元时有所不同。例如,数据库的路径,在生产中~/.app/data.db是/tmp/<randomid>/data.db在测试时。使用摩卡咖啡,我只会检查是否it存在,但在这里我不能
我正努力node-fetch在我的打字稿项目中工作:
import * as fetch from 'node-fetch';
import * as assert from 'assert';
export class DatabaseConfigurator {
private url: string;
getNode (): Promise<string> {
return fetch(`${this.url}/_membership`).then((response: fetch.Response) => {
return response.json();
}).then((res: any) => {
assert.equal(res.all_nodes.length, 1);
return res.all_nodes[0];
});
}
}
Run Code Online (Sandbox Code Playgroud)
我得到:
Cannot invoke an expression whose type lacks a call signature. Type 'typeof "/home/vinz243/compactd/node_modules/@types/node-fetch/index"' has no compatible call signatures.
Run Code Online (Sandbox Code Playgroud)
当我安装的定义似乎ok(node_modules/@types/node-fetch/index.d.ts):
...
export default function fetch(url: string | Request, init?: RequestInit): Promise<Response>;
Run Code Online (Sandbox Code Playgroud)
我的 tsconfig.json
{ …Run Code Online (Sandbox Code Playgroud) UI-Router文档显示您可以在路径名中使用点:
Run Code Online (Sandbox Code Playgroud)<!-- partials/state1.html --> <h1>State 1</h1> <hr/> <a ui-sref="state1.list">Show List</a> <div ui-view></div>
但是在我的应用程序中,这不起作用.这是一个很好的例子,直到我改变client到client.ts任何地方:
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<title>AngularJS: UI-Router Quick Start</title>
<!-- Bootstrap CSS -->
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" ui-sref="index">Quick Start</a>
<ul class="nav">
<li><a ui-sref="index">Home</a></li>
<li><a ui-sref="clien.ts">Clients</a></li>
<li><a ui-sref="route1">Route 1</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="span6">
<div class="well" ui-view=""></div>
</div>
<div class="span6">
<div class="well" ui-view="viewB"></div>
</div>
</div>
<!-- Angular -->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></script>
<!-- UI-Router -->
<script …Run Code Online (Sandbox Code Playgroud) 是否可以创建一个返回如下几个元素的函数:
def foo():
return 'b', 'c', 'd'
print ['a', foo(), 'e'] # ['a', 'b', 'c', 'd', 'e']
Run Code Online (Sandbox Code Playgroud)
我试过这个,但它不起作用
有没有一种方法可以从java类声明方法,以便可以将其作为infixkotlin中的函数进行调用,如下所示:
public class Foo {
public void doFoo (String bar) {}
}
Run Code Online (Sandbox Code Playgroud)
然后从kotlin文件
foo doFoo "bar"
Run Code Online (Sandbox Code Playgroud) 在我的html代码中,我使用的<a>标签为空,<href>因为一开始不知道url。
假设现在有一个新目标被称为“ www.amazon.de”。现在,我尝试使用javascript更改href:
document.getElementById('linkname').setAttribute("href", "www.amazon.de");
Run Code Online (Sandbox Code Playgroud)
但是我的浏览器仅创建到我域的相对链接,如下所示:
https://www.mydomain.de/www.amazon.de>
Run Code Online (Sandbox Code Playgroud)
(如果我将鼠标悬停在链接上,则会显示此内容)
我对Travis-CI进行了长时间的jasmine测试,但是在最新的提交中我得到了错误,Cannot find module Q而在package.json中遇到了依赖.如果我在本地运行它们,测试通过.
Message:
Error: Cannot find module 'Q'
Stacktrace:
Error: Cannot find module 'Q'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/travis/build/CraftYourModCorporation/OpenCubes/lib/api/mods.js:18:7)
at Object.<anonymous> (/home/travis/build/CraftYourModCorporation/OpenCubes/lib/api/mods.js:453:4)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Run Code Online (Sandbox Code Playgroud)
node.js ×3
javascript ×2
angularjs ×1
ava ×1
cors ×1
dropzone.js ×1
dsl ×1
fetch-api ×1
git ×1
href ×1
imgur ×1
jasmine-node ×1
java ×1
kotlin ×1
mklink ×1
python ×1
setattribute ×1
symlink ×1
travis-ci ×1
typescript ×1
unit-testing ×1
windows ×1