小编Uma*_*oon的帖子

获得"Stream不支持写作".以下代码中的异常

我正在尝试将图像上传到Amazon S3,但在此之前我正在调整图像大小.为了调整大小,我必须传递流对象并在某一点(行注释为//错误)我得到'流不支持写入'.例外.请帮忙.

 public ActionResult AddPost(AddPost post)
    {
        Guid guid = new Guid();
        AccountController ac=new AccountController();

        string randomId = guid.ToString();

        PutAttributesRequest putAttributesAction = new PutAttributesRequest().WithDomainName("ThisIsMyEXDomainPosts").WithItemName(randomId);

        List<ReplaceableAttribute> attrib = putAttributesAction.Attribute;

        System.IO.Stream stream;

        System.IO.StreamReader sr = new System.IO.StreamReader(post.imageFileAddress.ToString());


        sr.ReadToEnd();

        stream = sr.BaseStream;

        Amazon.S3.Model.PutObjectRequest putObjectRequest = new Amazon.S3.Model.PutObjectRequest();

        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);

        System.Drawing.Image imgResized = ResizeImage(img, 640, 800);

        System.IO.MemoryStream mstream = new System.IO.MemoryStream();

        imgResized.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);

        mstream.WriteTo(stream);//Error

        putObjectRequest.WithBucketName("TIMEXImages");
        putObjectRequest.CannedACL = Amazon.S3.Model.S3CannedACL.PublicRead;
        putObjectRequest.Key = randomId + "_0.jpg";
        putObjectRequest.InputStream = stream;

        Amazon.S3.Model.S3Response s3Response = as3c.PutObject(putObjectRequest);
        s3Response.Dispose();

        //Uploadig …
Run Code Online (Sandbox Code Playgroud)

.net c# stream

5
推荐指数
1
解决办法
1万
查看次数

init 与 wp_loaded:与示例有何不同?

我知道当大多数 WordPress 已加载但未发送标头时init会被触发,而当大多数 WordPress 已加载且标头已发送时wp_loaded会被触发。

有人可以用一个例子来解释什么可以使用这些钩子,什么不能使用这些钩子,并通过用例场景来解释和澄清它们的区别吗?

wordpress

4
推荐指数
1
解决办法
4354
查看次数

performSegueWithIdentifier无法正常工作

我有这个代码,当按下按钮时,它会加载一个新的UIView(来自storyboard).goPressed函数在按下按钮时触发,它调用selectImage函数.selectImage打开一个UIImagePickerController,让用户选择一张照片.用户选择照片后,didFinishPickingMediaWithInfo委托将所选图像添加到UIImageView.

在'goPressed'中,在执行selectImage之后,它应该执行一个类似于// 1的Segue.但没有任何反应.performSegueWithIdentifier似乎不起作用.如果我在调用performSegueWithIdentifier之前没有调用[self selectImage],它就可以了.这是代码:

- (IBAction)goPressed:(id)sender {
    [self selectImage];
    [self performSegueWithIdentifier:@"lastView" sender:currentSender]; //1
}
-(void)selectImage
{
    // Create image picker controller
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

    // Set source to the camera
    imagePicker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

    // Delegate is self
    imagePicker.delegate = (id)self;

    // Allow editing of image ?
    imagePicker.allowsEditing=NO;


    // Show image picker
    [self presentModalViewController:imagePicker animated:YES];


}

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    // Access the uncropped image from info dictionary
    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

    [[picker presentingViewController] …
Run Code Online (Sandbox Code Playgroud)

delegates objective-c ios5 segue

3
推荐指数
1
解决办法
1万
查看次数

在没有缩略图的Woocommerce Wordpress Plugin中显示产品类别列表

我使用以下短代码列出woocommerce Wordpress插件中的产品类别

<?php echo do_shortcode('[product_categories number=""]'); ?>
Run Code Online (Sandbox Code Playgroud)

问题是我需要摆脱的类别缩略图.我想隐藏它,用CSS做这件事似乎是个大麻烦.无论如何我可以在没有缩略图出现的情况下列出类别吗?

wordpress wordpress-plugin woocommerce

3
推荐指数
1
解决办法
2万
查看次数

Auto positioning div as one scrolls the page down/up

Please see this UI sketch image, I have this div in sidebar (black box) on a certain site and as I scroll down or scroll up, I don't want it to hide...I want it to move itself down as I scroll down and move itself up as I scroll back up so that it never hides out. Can you recommend me some jQuery that can get this done? or something else. Please help, thanks.

html css

1
推荐指数
1
解决办法
2993
查看次数

从ASP.NET MVC中的URL获取字符串

使用控制器中的以下代码,我可以使用此url将类型的值传递为"rock":"http:// localhost:2414/Store/Browse?genre = rock"

public string Browse(string genre)
    {
        string message = HttpUtility.HtmlEncode("Store.Browse, Genre = "
    + genre);

        return message;
    }
Run Code Online (Sandbox Code Playgroud)

当URL为"http:// localhost:2414/Store/Browse/rock"时,我想传递相同的类型值

我怎样才能做到这一点?

asp.net-mvc

1
推荐指数
1
解决办法
554
查看次数

初始化NSURL对象时,"线程1:在断点处停止"错误

我正在关注iTunes U上的斯坦福大学iOS开发课程.

在其中一个演示中(我一直试图遵循),有一个代码从a加载属性列表NSURL并将其返回为NSMutableDictionary.

-(NSMutableDictionary *) words
{

    NSURL *wordsURL=[NSURL URLWithString:@"http://cs193p.stanford.edu/vocabwords.txt"];

    words=[[NSMutableDictionary dictionaryWithContentsOfURL:wordsURL] retain];


    return words;
}
Run Code Online (Sandbox Code Playgroud)

应用程序已成功构建,但在运行时它会出现以下错误并被卡住:

Xcode在断点处停止的屏幕截图

我无法弄清楚问题是什么.你能帮忙吗?

breakpoints objective-c ios xcode4.3

1
推荐指数
1
解决办法
5677
查看次数