ImageShack and Shell programing

  • Thread starter rootX
  • Start date
  • Tags
    Shell
In summary, you copied all of the Java script from ImageShack and put it in your project, but there are a few problems that you need to fix.
  • #1
rootX
478
4
I am creating a product (for personal use)
when I left click an image, "Upload to ImageShack" should show up
and when I click that I want to upload the file to image shack and provide me the uploaded file address in dialog box/other ways

Currently, I am working on .Net web application. I copied all java script from image shack and put it under my project. It is almost done (few problems)

Then, I am thinking of making an .exe file that would start this web application or it might talk to imageshack directly.
http://imageshack.us/

And, that "Upload to ImageShack" should start the .exe program.

Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Notepad]

[HKEY_CLASSES_ROOT\*\shell\Open with Notepad\command]
@="notepad.exe %1"

This opens up notepad, and I want to make similar that opens my program and provide file location as a parameter.

Any help would be appreciated!This is my second personal project. In the first one, I created excel 2007 add-in that emails my files to gmail account when I click a button (I really wanted it for backing up my data and remote use)
If there's a better way to achieve the final functioning?
 
Last edited:
Technology news on Phys.org
  • #2
ImageShack has an API:
http://reg.imageshack.us/content.php?page=developer

Using the XML API provided should be easy to integrate.

Refer to php code: http://elliottback.com/wp/archives/2008/06/01/using-the-imageshack-xml-api/

The code provided, should be fairly easy to modify and convert to .NET code.

Imageshack some simple examples to using their API once you have requested for a developer key. But these are geared towards web based applications.
 
Last edited by a moderator:
  • #3
dashed said:
ImageShack has an API:
http://reg.imageshack.us/content.php?page=developer

Using the XML API provided should be easy to integrate.

Refer to php code: http://elliottback.com/wp/archives/2008/06/01/using-the-imageshack-xml-api/

The code provided, should be fairly easy to modify and convert to .NET code.

Imageshack some simple examples to using their API once you have requested for a developer key. But these are geared towards web based applications.

Thanks that was neat!

using HttpRequest class, it's simple 20 lines code but mine didn't work. Doesn't return anything
One question: I passed file name first and then file stream .. none worked :cry:

they say

Send the following variables via POST to http://www.imageshack.us/index.php

fileupload; (the image)
xml = "yes"; (specifies the return of XML)
cookie; (registration code, optional)
Assuming the upload completes without problems, the xml data may be manipulated as necessary. To show the user the results of his or her upload, redirect the user to <done_page>, as defined in the XML feedback agent.

my code:
Code:
string fileName = "C:\\Documents and Settings\\Harmeet Cheema\\My Documents\\My Pictures\\Avril.JPG";
            
StreamReader streamRdr = new StreamReader(fileName);
            String file = streamRdr.ReadToEnd();
            byte[] buffer = Encoding.Unicode.GetBytes("fileupload=" + file + "&xml=yes");
            //Initialisation, we use localhost, change if appliable
            HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("http://www.imageshack.us/index.php");
            //Our method is post, otherwise the buffer (postvars) would be useless
            WebReq.Method = "POST";
            //We use form contentType, for the postvars.
            WebReq.ContentType = "application/x-www-form-urlencoded";
            //The length of the buffer (postvars) is used as contentlength.
            WebReq.ContentLength = buffer.Length;
            //We open a stream for writing the postvars
            Stream PostData = WebReq.GetRequestStream();
            //Now we write, and afterwards, we close. Closing is always important!
            PostData.Write(buffer, 0, buffer.Length);
            PostData.Close();
            //Get the response handle, we have no true response yet!
            HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
            //Let's show some information about the response
            Console.WriteLine(WebResp.StatusCode);
            Console.WriteLine(WebResp.Server);
 
Last edited by a moderator:
  • #4
But, using dirty solution. Make direct post to their page, I managed to get the file address..

Now,
I have a .EXE console application that would return the photo uploaded http address when you pass the file address to it from args.

So, I am left it putting it together with context menu
 
  • #5
I recommend using the curl library when communicating with a web service. I don't know if .NET has native functions for this.

http://curl.haxx.se/libcurl/dotnet/

Their PHP example: http://reg.imageshack.us/xmlapi.zip

PHP:
        function uploadToImageshack($filename) {

                //Connect to imageshack
                $ch = curl_init("http://www.imageshack.us/index.php");
                
                //$_POST data
                $post['xml']='yes';
                $post['fileupload']='@'.$filename;

                //curl stuff
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_HEADER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_TIMEOUT, 240);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: '));

                $result = curl_exec($ch);
                curl_close($ch);

                if (strpos($result, '<'.'?xml version="1.0" encoding="iso-8859-1"?>') === false) {
                        return 'failed';
                } else {
                        return $result; // XML data
                }
        }

Try to convert this function into .NET code. The parameter $filename is the image store temporarily on disk to be uploaded to imageshack.

The xml data should be within the variable $result.

Use a xml parser to get the information you need.

You may use a .NET xml parser (I don't know if .NET provides this function natively):
http://www.chilkatsoft.com/dotNetXml.asp


I hope this helps.
 
Last edited by a moderator:
  • #6
dashed said:
I recommend using the curl library when communicating with a web service. I don't know if .NET has native functions for this.

http://curl.haxx.se/libcurl/dotnet/

Their PHP example: http://reg.imageshack.us/xmlapi.zip

PHP:
        function uploadToImageshack($filename) {

                //Connect to imageshack
                $ch = curl_init("http://www.imageshack.us/index.php");
                
                //$_POST data
                $post['xml']='yes';
                $post['fileupload']='@'.$filename;

                //curl stuff
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_HEADER, false);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_TIMEOUT, 240);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: '));

                $result = curl_exec($ch);
                curl_close($ch);

                if (strpos($result, '<'.'?xml version="1.0" encoding="iso-8859-1"?>') === false) {
                        return 'failed';
                } else {
                        return $result; // XML data
                }
        }

Try to convert this function into .NET code. The parameter $filename is the image store temporarily on disk to be uploaded to imageshack.

The xml data should be within the variable $result.

Use a xml parser to get the information you need.

You may use a .NET xml parser (I don't know if .NET provides this function natively):
http://www.chilkatsoft.com/dotNetXml.asp


I hope this helps.

Thanks, I will look further into that way.

Currently, I have one working solution, so I just want to get done the whole thing working before I start making it cleaner.

Context menu click --> open .exe and provide file location as args paramter...
 
Last edited by a moderator:
  • #7
Instead of a custom entry in the context menu, you can consider using "send to".

Simply make your imageshack.exe take a filename as the first parameter, then put imageshack.exe in the "documents and settings\name\send to\" folder.

Then you can right-click any file, go to "send to" and choose imageshack.

k
 
  • #8
kenewbie said:
Instead of a custom entry in the context menu, you can consider using "send to".

Simply make your imageshack.exe take a filename as the first parameter, then put imageshack.exe in the "documents and settings\name\send to\" folder.

Then you can right-click any file, go to "send to" and choose imageshack.

k

Thanks that was easy! Finished in 5 seconds :). I couldn't find send to in C:\doc .. so I ran "sendto" from run.

Now, I have simple application that uploads the file, returns in console and works perfectly!
Need to work on making it more user friendly .. and cleaner

I will upload my code shortly. It would be less than 100 lines (now it's about 200 ..)
 
  • #9
Thanks guys!
I am done :biggrin:

http://img237.imageshack.us/img237/2569/screen1rc1.png
Select the file
http://img519.imageshack.us/img519/7682/screen2uv9.png
Click on the upload button
http://img237.imageshack.us/img237/8623/screen3tp1.png
It anagrammatically copies to the clipboard!
 
Last edited by a moderator:
  • #10
rootX said:
Thanks guys!
I am done :biggrin:

http://img237.imageshack.us/img237/2569/screen1rc1.png
Select the file
http://img519.imageshack.us/img519/7682/screen2uv9.png
Click on the upload button
http://img237.imageshack.us/img237/8623/screen3tp1.png
It anagrammatically copies to the clipboard!

And, it's possible to upload multiple files and all images in a directory.
 
Last edited by a moderator:

Related to ImageShack and Shell programing

1. What is ImageShack?

ImageShack is an online image hosting service that allows users to upload, store, and share images. It provides a simple and convenient way to host images for personal or professional use.

2. How does ImageShack work?

When a user uploads an image to ImageShack, the image is stored on the ImageShack server and assigned a unique URL. This URL can then be shared with others to access the image. Users can also organize their images into different albums for easier management.

3. What is Shell programming?

Shell programming is the practice of creating and running scripts written in a shell language, such as Bash, to automate tasks or execute a series of commands. It is commonly used in operating systems to manage files, run programs, and perform other system tasks.

4. How can Shell programming be used with ImageShack?

Shell programming can be used with ImageShack to automate the uploading of images. A user can write a script that automatically uploads images to ImageShack, eliminating the need to manually upload each image. This can save time and effort, especially for users who frequently upload images to ImageShack.

5. Is Shell programming difficult to learn?

The difficulty level of learning Shell programming depends on a person's previous programming experience. For beginners, it may take some time to understand the syntax and concepts, but with practice and dedication, it can be mastered. There are also numerous online resources and tutorials available to help beginners learn Shell programming.

Similar threads

  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
9
Views
2K
  • Programming and Computer Science
Replies
3
Views
981
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
22
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
9
Views
997
  • Programming and Computer Science
Replies
19
Views
3K
Back
Top