在我的Angular JS项目中,我有一个<a>锚标记,当单击它时会GET向返回文件的WebAPI方法发出HTTP 请求.
现在,我希望在请求成功后将文件下载到用户.我怎么做?
锚标记:
<a href="#" ng-click="getthefile()">Download img</a>
Run Code Online (Sandbox Code Playgroud)
AngularJS:
$scope.getthefile = function () {
$http({
method: 'GET',
cache: false,
url: $scope.appPath + 'CourseRegConfirm/getfile',
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
}).success(function (data, status) {
console.log(data); // Displays text data if the file is a text file, binary if it's an image
// What should I write here to download the file I receive from the WebAPI method?
}).error(function (data, status) {
// ...
});
}
Run Code Online (Sandbox Code Playgroud)
我的WebAPI方法: …
所以我想要做的是快速创建并播放声音,当我按下按钮时会播放,我知道如何在Objective-C中执行此操作,但有人知道如何在Swift中播放吗?
对于Objective-C,它会是这样的:
NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"mysoundname" ofType:@"wav"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundURL, &mySound);
Run Code Online (Sandbox Code Playgroud)
然后玩它我会做:
AudioServicesPlaySystemSound(Explosion);
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么做到这一点?
我正在尝试创建一个自定义的UIButton UIButtonType.RoundedRect.
我添加的功能正在运行,但是我的按钮的初始圆形边框状态存在问题.我的扩展按钮的边框在点击之后才会被绘制.

更新(2013年1月24日):根据Richard Marskell的要求添加了红色背景测试的结果,该结果仅得出按钮的标签. BackgroundColor = UIColor.Red;

以下是我创建自定义按钮的源代码.
public class TestView : UIView
{
public TestView(IntPtr p) : base(p) { }
public TestView(RectangleF bounds)
{
Frame = bounds;
BackgroundColor = UIColor.White;
UIButton button1 = new UIButton(UIButtonType.RoundedRect);
button1.Frame = new RectangleF(20,20,100,50);
button1.SetTitle("Button 1", UIControlState.Normal);
AddSubview(button1); // Drawn Correctly
MyButton button2 = new MyButton();
button2.Frame = new RectangleF(20,90,100,50);
button2.SetTitle("Button 2", UIControlState.Normal);
AddSubview(button2); // Only drawn correctly after Tap
// EDIT: Added to test Miguel's theory
UIButton button3 = UIButton.FromType(UIButtonType.RoundedRect);
button3.Frame …Run Code Online (Sandbox Code Playgroud) 输入时:
redis-cli救了
我不知道dump.rdb保存在哪里(因为redis是作为服务而不是在我的本地目录中启动的).
有没有我可以指定一个文件名来"保存",所以我输入如下内容:
redis-cli save~/db-2012-06-24.rdb
谢谢
我有一个对象,我使用ToJson<>()ServiceStack.Text命名空间中的方法反序列化.
如何GET在序列化过程中省略所有唯一的属性?是否有任何属性[Ignore]或类似我可以用我的属性装饰,以便它们可以省略?
谢谢
我是第一次构建服务堆栈:hello world.
但它给了我一个错误:找不到请求处理程序:可能缺少的部分是什么?谢谢.
这是我的global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.SearchService
{
public class Global : System.Web.HttpApplication
{
public class Hello { public string Name { get; set; } }
public class HelloResponse { public string Result { get; set; } }
public class HelloService : IService<Hello>
{
public object Execute(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name }; …Run Code Online (Sandbox Code Playgroud) 我需要使用Google BigQuery API查询数据.但是我很难找到.NET Samples,而且二进制文件中没有包含任何文档(Google.Apis.Bigquery.dll).任何人都可以为我提供.NET的示例用法吗?
我现在已经扫描了几乎所有内容,而他们解决的大多数人只是在S3服务上配置CORS,这对我来说不起作用.我肯定错过了什么.在这里:
我正在尝试使用客户端的Ajax调用将我的文件上传到Amazon S3.我知道我的策略/签名是正确的,因为它只是在我提交表单时有效,但是当我尝试用它进行Ajax调用时,我得到了
Origin "my host" is not allowed by Access-Control-Allow-Origin.
Run Code Online (Sandbox Code Playgroud)
错误.我的表格:
<form id="fileform" action="https://mybucket.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="mykey">
<input type="hidden" name="AWSAccessKeyId" value="myaccesskey">
<input type="hidden" name="acl" value="public-read">
<input type="hidden" name="Content-Type" value="image/jpeg">
<input type="hidden" name="policy" value="mypolicy">
<input type="hidden" name="signature" value="mysignature">
</form>
Run Code Online (Sandbox Code Playgroud)
在我的CORS中,我几乎允许一切,因为我很绝望:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
选择一个文件并提交表单(通过点击它或使用jQuery)就像一个魅力,但是使用序列化表单执行Ajax请求会给我带来错误.
var form = $('#fileform');
$.ajax({
url: "https://mybucket.s3.amazonaws.com/",
type: 'post',
crossDomain: true,
dataType: 'xml',
data: form.serialize()
});
Run Code Online (Sandbox Code Playgroud)
我知道这与CORS规则有关,但正如你所看到的那样,它们已经建立起来了.因此,任何人都知道还有什么可能是错的?
谢谢.
我正在设计一个使用Redis作为数据库的Web服务,我想知道使用Redis连接StackService客户端的最佳实践.
关键是我一直在阅读Redis,我发现与服务器交互的最佳方式是使用单个并发连接.
问题是,尽管每次Web客户端向Web服务发出请求时我都在使用PooledRedisClientManager,但我得到了一个连接到redis服务器的连接客户端(打开的连接),并且这个连接的客户端数量增加了更多的记忆.
样本'故障'代码:
PooledRedisClientManager pooledClientManager = new PooledRedisClientManager("localhost");
var redisClient = pooledClientManager.GetClient();
using (redisClient)
{
redisClient.Set("key1", "value1");
}
Run Code Online (Sandbox Code Playgroud)
我为解决这个问题所做的是创建一个用静态RedisClientvar 实现单例模式的类; 如果redisClient未初始化,则创建一个新的,如果是,则返回初始化的.
解:
public class CustomRedisPooledClient
{
private static CustomRedisPooledClient _instance = null;
public RedisClient redisClient = null;
// Objeto sincronización para hacer el Lock
private static object syncLock = new object();
private CustomRedisPooledClient()
{
redisClient = new RedisClient("localhost");
}
public static CustomRedisPooledClient GetPooledClient()
{
if (_instance == null)
{
lock (syncLock)
{
if …Run Code Online (Sandbox Code Playgroud) 我在Ubuntu上使用upstart来管理服务.它写道/var/log/upstart/<service>.log.此文件中的错误没有时间戳,这使得诊断问题变得困难.
是否有一种方法 - 配置文件中的某种类型 - 告诉upstart用其日志输出写入时间戳?
c# ×3
servicestack ×3
redis ×2
.net ×1
ajax ×1
amazon-s3 ×1
angularjs ×1
asp.net ×1
audio ×1
cors ×1
html ×1
ignore ×1
ios ×1
javascript ×1
jquery ×1
json ×1
logging ×1
mono ×1
objective-c ×1
properties ×1
swift ×1
uibutton ×1
uikit ×1
upstart ×1
web-services ×1
xamarin.ios ×1
xss ×1