Cannot upload picture from hard drive to eBay sandbox with API - c#

I tried to upload my picture but it didn't work. I know sandbox doesn't support photos but I mean inside the sandbox listing there is main photo. Other sellers have a main photo so there must be a way.
My code compiles without an error but there just isn't a photo when I go to the sandbox. Here is the code I'm using:
apiCall.PictureFileList = new StringCollection();
apiCall.PictureFileList.Add(#"C:\Users\Danny\Desktop\deleteMeBiggerEbayPic.jpg");
item.PictureDetails = new PictureDetailsType();
item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery;

Afaik you can't upload pictures from your local hard-drive using the eBay SOAP API. You need to sepcify a public URL where eBay can download the image from.
BTW: The sandbox supports photos, the only thing it doesn't support are gallery images.

I decided to try the original code again and to my surprise it worked. Maybe I did something wrong but I cant be bothered checking, its working now.
Here is the code:
//Set the Picture Server URL for Sandbox
apiContext.EPSServerUrl = "https://api.sandbox.ebay.com/ws/api.dll";
//For production use this URL
//context.EPSServerUrl = "https://api.ebay.com/ws/api.dll";
//Set file path of the picture on the local disk
apiCall.PictureFileList = new StringCollection();
apiCall.PictureFileList.Add(#"C:\Users\Danny\Desktop\MyGalleryPicOnHardDrive.jpg");
//To specify a Gallery Image
item.PictureDetails = new PictureDetailsType();
//The first picture is used for Gallery URL
item.PictureDetails.GalleryType = GalleryTypeCodeType.Gallery;
//To add more pictures
//apiCall.PictureFileList.Add(#"C:\TEMP\pic2.gif");

Related

File downloaded from gdrive is corrupted

I have a problem downloading file from gdrive
I am using this code
DriveService service = new DriveService();
var Stream = service.HttpClient.GetStreamAsync("https://drive.google.com/open?id=blablabla");
var result = Stream.Result;
using (var fileStream = System.IO.File.Create("MyFile.exe"))
{
result.CopyTo(fileStream);
}
But I am getting size of 103kB in MyFile.exe, and it has 800 kB.
I suspect that I am not getting download url right, as I right click on the file I want to download and get shareable link in this format: https://drive.google.com/open?id=blablaid
According to www.labnol.org/internet/direct-links-for-google-drive/28356/ the Google Drive download link is https://docs.google.com/uc?export=download&id=[FILE_ID].
Otherwise you could also look at the Google Drive REST API (developers.google.com/drive/v3/web/manage-downloads).

C# facebook sdk post animated gif

I'm trying to develop an application for posting animated gifs directly to a facebook wall of a logged user.
Everything works fine with static images, but when I try to upload animated gif, only first frame is shown on a user wall...
My code is:
FileInfo file = new FileInfo(System.IO.Path.GetFullPath(printfile));
FacebookMediaObject facebookUploader = new FacebookMediaObject { FileName = file.FullName, ContentType = "image/gif" };
var bytes = File.ReadAllBytes(file.FullName);
facebookUploader.SetValue(bytes);
var postInfo = new Dictionary<string, object>();
postInfo.Add("image", facebookUploader);
FBClient.Post("/me/photos", postInfo);
What am I doing wrong? I have done a little searching in this topic, I'm know that in the past it wasn't even possible to publish animated gifs on facebook, but now I can see there is a lot of animated gifs on facebook, so it's seems to me it's possible now...
Unfortunately, facebook c# sdk is a third party software and I cant find a good documentation for it. I know that it is somewhere in the internet, but I can't find it... I would be very gratefull if you could help me find a good one.
I would appreciate every clue and answer.
Thank you in advance.

Fine Uploader session Thumbnails slow to load

I'm creating a mockup file upload tool for a community site using Fine Uploader.
I've got the session set up to retrieve the initial files from the server along with a thumbnail url.
It all works great, however the rendering of the thumbnails is really slow.
I can't work out why. So I hard-coded to use a very small thumbnail for each of the four files. This made no difference.
The server side not the issue. The information is coming back very quickly.
Am I doing something wrong? Why is fineuploader so slow? Here's screen grab. It's taking four seconds to render the four thumbnails.
I'm using latest chrome. It's a NancyFX project on a fairly powerful machine. Rending other pages with big images on them is snappy.
Client side code:
thumbnails: {
placeholders: {
waitingPath: '/Content/js/fine-uploader/placeholders/waiting-generic.png',
notAvailablePath: '/Content/js/fine-uploader/placeholders/not_available-generic.png'
}
},
session: {
endpoint: "/getfiles/FlickaId/342"
},
Server side code:
// Fine uploader makes session request to get existing files
Get["/getfiles/FlickaId/{FlickaId}"] = parameters =>
{
//get the image files from the server
var i = FilesDatabase.GetFlickaImagesById(parameters.FlickaId);
// list to hold the files
var list = new List<UploadedFiles>();
// build the response data object list
foreach (var imageFile in i)
{
var f = new UploadedFiles();
f.name = "test-thumb-small.jpg"; // imageFile.ImageFileName;
f.size = 1;
f.uuid = imageFile.FileGuid;
f.thumbnailUrl = "/Content/images/flickabase/thumbnails/" + "test-thumb-small.jpg"; // imageFile.ImageFileName;
list.Add(f);
}
return Response.AsJson(list); // our model is serialised by Nancy as Json!
};
This is by design, and was implemented both to prevent the UI thread from being flooded with the image scaling logic and to prevent a memory leak issue specific to Chrome. This is explained in the thumbnails and previews section of the documentation, specifically in the "performance considerations" area:
For browsers that support client-generated image previews (qq.supportedFeatures.imagePreviews === true), a configurable pause between template-generated previews is in effect. This is to prevent the complex process of generating previews from overwhelming the client machine's CPU for a lengthy amount of time. Without this limit in place, the browser's UI thread runs the risk of blocking, preventing any user interaction (scrolling, etc) until all previews have been generated.
You can adjust or remove this pause via the thumbnails option, but I suggest you not do this unless you are sure users will not drop a large number of complex image files.

Saving images from IP Camera to folder in application

I have a camera connected to a network that provides images which can be accessed by IP. For example something like this.
http://170.1.2.3/image?camera=2
I get returned a jpg file, which I can easily display back on a webpage using normal html.
<img src="http://170.1.2.3/image?camera=2" />
But instead of simply showing the camera image as seen from the time of the page load, I also want to save this image locally to the server using an MVC4 application. In addition it would be nice to include a timestamp on the filename. I'm not having any luck finding an example that looks right to me.
Let's say I want to start with the most basic example:
string imgUrl = "http://170.1.2.3/image?camera=2";
savelocally(imgurl, "newfilename-"+DateTime.Now.ToString());
.. and savelocally() should place the file in "~/Uploads". How do I do this? All the examples I've come across have been for uploading a file from desktop. I don't know how to translate that into grabbing a remote image.
Update:
This is an incomplete answer, as pointed out by comments.
string url = "http://170.1.2.3/image?camera=2";
string localFilename = #"C:\Projects\MvcApplication1\MvcApplication1\Uploads\tofile.jpg";
using (WebClient client = new WebClient())
{
client.DownloadFile(url, localFilename);
}
It works, however I don't like the fact that the file path is an absolute one. I tried replacing localFilename with ~/Uploads/tofile.jpg but it results in an error on execution. If possible I want to avoid having a fixed location for the upload folder.

Where do my images go when i use FileUpload1.SaveAs(Server.MapPath())?

Originally I started having the images put into a database and using generic handler to view the images, it was ok for one part of my app but then I realized that storing images in the database wasn't going to work out to well for a part of my application because I will be dynamically creating an html table with hyperlinks and using images for hyperlinks.
So using generic handlers would see to be a huge mess when creating the html and navigation hyperlinks,
So what I have opted to do is now is put these images to a folder on the server, but right now I am using my laptop before I even get to the point of publishing the app on line.
So this is the code I am using...
string iconName = fpIcon.FileName;
string iconExtension = Path.GetExtension(iconName);
string iconMimeType = fpIcon.PostedFile.ContentType;
string[] matchExtension = { ".jpg", ".png", ".gif" };
string[] matchMimeType = { "image/jpeg", "image/png", "image/gif" };
if (fpIcon.HasFile)
{
if (matchExtension.Contains(iconExtension) && matchMimeType.Contains(iconMimeType))
{
fpIcon.SaveAs(Server.MapPath(#"~/Images/" + iconName));
Image1.ImageUrl = #"~/Images/" + iconName;
}
}
So my question is, and don't laugh to hard but, where are these images being stored? I can't find them anywhere on my laptop using the windows search. With all the images that I have in this ~/Images directory, I can change the image to any image I wanted by supplying the name, but I have no idea where the images are being held, and when I do deploy to a site then where are they going to be then?
Thanks
Server.MapPath gives your current website directory(IIS hosted or running from VS). So go to your website directory, find Images directory there and you'll see your images.

Categories