Upload completed with errors or some files were cancelled.

Dec 10, 2011 at 2:53 PM

I get this error when I try to to upload a in localhost.

I copied the code from the quickstart and it's not working..

Hope somebody can help me,

Thanks.

Coordinator
Dec 10, 2011 at 5:12 PM

Can you provide more details, so we can help?

Dec 10, 2011 at 10:21 PM

Hi sorry for the bad explanation, english isn't my first language.

I copied the code from the quickstart documention, I manage to get it running.
I press the Upload button, the menu to select a file comes up, I select a file and then the Interlink window opens.

Next I press "Upload" and then I just get the following error: Upload completed with errors or some files were cancelled.

Not sure what I'm doing wrong or how I can see what error I am getting?

Thank you for your time :)

Coordinator
Dec 10, 2011 at 10:24 PM

Usually that happens when the client cannot connect to the server. Are you using IIS Express or VS2010 (Cassini)?

Put a break point in the constructor of your UploadHandler and see if it's getting created. If it is,  then put a break point in your OnError override to see if you're getting any errors.

Let us know what you find...

Dec 10, 2011 at 10:30 PM

I'm using Visual Studio 2010 and I put a break in the constructor of the UploadHandler like this: http://localhostr.com/files/zXjyiel/capture.png

But when I press the "Upload" button, It doesn't do anything, it doesn't go to the breakpoint, so I guess the UploadHandler isn't being created?

Coordinator
Dec 10, 2011 at 10:32 PM

Is your project an Web Application or a Web Site? if it's a site, ASP.NET mangles the class names and namespaces. If you're using a web site, you'll have to build your file-handler in a separate project, and then drop the dll in the bin folder and update your appsettings to point to the proper type name and assembly.

Dec 12, 2011 at 9:36 AM

I think it's a web Application, I have a normal project in it and a .Web Project in it. What does it make that?

Coordinator
Dec 12, 2011 at 5:05 PM

Do you have an app_code folder? Does your project show the path to your files?

Dec 12, 2011 at 5:38 PM

Yes, I have an app_code folder: this is what my structure looks like: http://localhostr.com/files/ngl5gso/capture.png

Coordinator
Dec 12, 2011 at 6:01 PM

Ok, you project is correct. Can you share your config? Are you using any custom routing etc? The client just re-uses the current url and post to http://yourUrl/filehandler.ashx so for your test project it would be something like http://localhost:port/filehandler.ashx

I also noticed you had client access policy, depending on how you have that configured it could be blocking the calls.

 

Dec 12, 2011 at 6:06 PM

I don't have a file called filehandler, the quick start never told me to create it?

I didn't do anything special with the client access policy, it was created automaticly.

You can find my web.config here: http://pastebin.com/4eH7DUZ6

Thanks :)

Coordinator
Dec 12, 2011 at 6:14 PM

OK, it's your web config.

1. The app setting should reference your upload handler. You still have the example values; should be something like (Full Type Name, Assembly Name) Ondernemers.UploadHandler, Ondernemers

2. You don't need to have a file called FileUpload.ashx, it's a virtual path that maps to the HSS Interlink HTTP Handler

3. You need to remove the [async] from the http handler mapping section. That was there to show that you can specify FileUpload or FileUploadAsync

Make those corrections, and it should work.

Dec 12, 2011 at 6:21 PM

I changed it to the following: http://pastebin.com/ve8yzinr

But I still get the same error: http://localhostr.com/files/Mnczx5b/capture.png

Sorry the inconvenience and thanks for helping me. :)

Coordinator
Dec 12, 2011 at 6:39 PM

Can you confirm that it is getting to your handler by putting a break point in the constructor? Are you running out of browser?

Dec 12, 2011 at 6:43 PM

I put the break point in the same place as before and it's still not getting there. I'm running inside browser.

This is my clientconifg, just in case: http://pastebin.com/a2ibVeWQ

Coordinator
Dec 12, 2011 at 6:43 PM

Oh, I just saw it, you have the handler mapping in the system.webserver section (which is for IIS 7 after you deploy it). For dev you have to put it in the system.web section (which is for IIS 6 or VS2010 Cassini)

Coordinator
Dec 12, 2011 at 6:45 PM

Be sure and read this from MSDN http://msdn.microsoft.com/en-us/library/46c5ddfy.aspx

 

Dec 12, 2011 at 6:48 PM

It worked, thank you! :D

Is there any quick way I can get the URL's of the files? (So I can put them on my website)

Coordinator
Dec 12, 2011 at 6:49 PM

I'm not sure what you're asking, what files?

Dec 12, 2011 at 6:51 PM

My apologies, I am quite bad at explaining stuff.

What I'm trying to do is let the user upload Images, and those images are then displayed on the website.

So I would try to get the URL of those uploaded images to show on my website.

Thanks :)

Coordinator
Dec 12, 2011 at 6:55 PM

It depends on what you do with the files they upload. If you save them to a folder within the application (something like /images/uploaded) then you could just navigate directly to them, http://localhost/images/uploaded/filename.ext

If you want them to be available from your SL application, then you use the DownloadFileDialog that is part of Interlink. If you review the complete example it walks you thru the process. Also if you download the source code, there is a complete working example. You can see it in action here http://hssinterlink.com

 

 

Dec 13, 2011 at 4:04 PM

Thanks,

But how would I know when I need to navigate to which image? (Depend on what page I am), and what filename to choose? (Because they can name it whatever they want).

For example, the user on the homepage can adjust the image on there by pressing the "upload" button, but how would my application then know what the IMG url is?

Thank you and my apologies if my questions aren't quite clear :)

Coordinator
Dec 13, 2011 at 5:31 PM

If you weren't using Interlink how would handle file names? I guess my point is, that's a challenge of you application in general. Someone uploads an image, and then you want to display at some point later on.

You could place the files in a user specific folder and then just enumerate the folder. What's your criteria for showing an image on a given page?

 

Dec 13, 2011 at 6:51 PM

There isn't any criteria really, I think all I need is a way to get the name of the uploaded image (the select one) and then do something like the following:

            string imageName = "something.jpeg";
            var ub = new UriBuilder(HtmlPage.Document.DocumentUri);
            ub.Path = "/Interlink/Uploads/" + imageName;
            image1.Source = new BitmapImage(ub.Uri);

But how would I get the name of the uploaded image?

Thanks :)

Coordinator
Dec 13, 2011 at 6:57 PM

I guess I still don't understand, in the sense that, if you take HSS Interlink out of the equation, and just assume you have a bunch of image files already on disk, how do you know what file you want?

How do you know you want something.jpg? Can you explain your workflow in which you want to show images to the user?

Dec 13, 2011 at 7:01 PM

My apologies!

So, the user comes on my page and he sees an image. Under the image there is an upload button.
If he presses that button he can than choose an image to upload which will be uploaded and shown instead of the previous image on that page.

So I would need the name of the image the user uploaded. The "something.jpg" will be replaced with the name of the image the user uploaded. So it will be set as the new image on the website.

I hope this makes it any clearer,

Thank you for your time!

Coordinator
Dec 13, 2011 at 7:09 PM

Ah, OK making progress. So how did you know to display something.jpg in the first place? Is it hardcoded? Is it something like their gravatar picture?

When you upload the image, there is a constructor overload of the UploadFileDialog that takes a callback delegate (Func<UploadFileViewModel, string> getMetadataCallback)

This callback gets called for each file that is uploaded, and provides you the UploadFileViewModel instance and contains the name of the file they're uploading. The return of  this delegate is a string which could contain additional metadata that you could send along with the file upload. If you don't need to send any metadata, then just return an empty string. 

Dec 13, 2011 at 7:20 PM

The "something.jpg" was/is just an a place-holder of what should come there. :)

If I understand correctly I have to overload the UploadFileDialog to return the string (which would be the name of the picture) I need.
I'm not quite sure how to do this, I am not a very experiences programmer as you may have noticed.

Again, my apologies and thank you :)

Coordinator
Dec 13, 2011 at 7:29 PM

http://interlink.codeplex.com/documentation

Please read the documentation. The last section shows how to leverage the Metadata callback. Again the intent of this callback is so you can pass additional data to the server, but can be also used to capture the name of the file they're uploading.

But I'm not sure that will solve your challenge. From the sounds of it, your real problem is how do you know what file to show, which has nothing to do with Interlink. You'd have the same challenge if you used the standard browser http file upload.

If you want to hire HSS to have us help build your application, we're more than happy to assist, I'll charge you our discounted rate of $65.00USD/hour.

Dec 14, 2011 at 5:47 PM

Thank you for the documention, although I don't understand how to call the method GetMetaData (or any method written in UploadHandler) I will continue into looking into it..

            var udialog = new HSS.Interlink.UploadFileDialog();
            udialog.MaxFileSizeKB = int.MaxValue;
            udialog.AllowFileOverwrite = true;
            udialog.BrowseAndShow();

udialog doesn't have any of the methods that UploadHandler has, so I don't understand where I would write the extra method GetMetaData.

I appreciate the offer on helping me build my application but seeing as I'm a student I can't afford it and I'm doing this project to learn.

Thanks for all the help you have given me so far. I really appreciate it.

Coordinator
Dec 14, 2011 at 5:54 PM

It's a callback delegate similar to an event handler.

If you copy the method signature from the docs for the GetMetadata method, you just pass that to the method name to the constructor.

// a class field
string myFileName = "";

// In a button click handler or method
var udialog = new UploadFileDialog(GetMetadata);
udialog.AllowMultiple = false;
udialog.AllowNew = false;

udialog.Show();

string

 GetMetadata(UploadFileViewModel file)
{
    this.myFileName = file.FileName;
    return string.Empty;
}

 

Dec 14, 2011 at 6:25 PM

Thank you, I'll give it a try tomorrow and I'll let you know if it works.