I have some client side code that uploads an Outlook email to a document library and as long as the path is pointing to the root of the doc library it works just fine.
#"https://<server>/sites/<subweb>/<customer>/<teamweb>/<Documents>/" + docname;
is the projectUrl in this function :
public bool SaveMail(string filepath, string projectUrl)
{
try
{
using (WebClient webclient = new WebClient())
{
webclient.UseDefaultCredentials = true;
webclient.UploadFile(projectUrl, "PUT", filepath);
}
}
catch(Exception ex)
{
//TO DO Write the exception to the log file
return false;
}
return true;
}
but I have not been able to figur out how to upload to an existing folder i.e. "Emails" in the same document library.
Not even Google seems to know the answer :-)
Note: I know that I could use something like the Copy web service within SharePoint to move the file to its final destination, but that is more like a workaround.
When will I learn not to work that late into the night :-(
Sorry about that question. Igalse is right, I just needed to add "emails/" to the URL. I could swear that I had tried that, but then again it sure looks like I didn't.
With your code I just added /Emails/ to the projectUrl and the upload worked just fine. Have you tried that? Maybe you have permission problem.
Related
Consider the following plugin...infrastructure build up omitted for brevity.
protected override void Execute()
{
//Not all Targets are of entity so let's check first
if (Context.InputParameters.Contains("Target") && Context.InputParameters["Target"] is Entity)
{
if (Message == EMessage.Create)
{
throw new InvalidPluginExecutionException("InCreate");
}
else if (Message == EMessage.Update)
{
//I don't think this is right way to do this.
if (PreEntityImage.GetAttributeValue<OptionSetValue>("componentstate").Value == new OptionSetValue(0).Value)
{
throw new InvalidPluginExecutionException("UpdatePublishedMessage");
}
else
{
throw new InvalidPluginExecutionException("UpdateMessageOnly");
}
}
}
}
This plugin is registered for the Create & Update message on webresource.
So when the webresource is created my plugin fires and branches into the Create message section.
When the webresource is updated I branch into the Update section AND flow right into componentstate == published section!!??
I would have thought any change would have been flagged unpublished until I selected publish or publishall?
Some other details that may be relevant:
The webresource I am working with is a js file. Perhaps this is not the behavior for other webresource types like png?
The steps I am taking in updating the webresource are:
Open Test Solution
Open webresource js file
Open with text editor
Make Edits
Click OK---and plugin fires.
Thoughts, tips, edjumakation etc. greatly appreciated
Thank You
When saved and not published, Crm creates another record in webresources table. So for unpublished resources you have two entries: one record with componentstate = 0 and one with componentstate= 1.
I guess plugin works on the one that have 0 value. You might try query table to check if there's any with value 1 to determine if it's published or not. Or check any there paras passed to plugin.
I am currently using a downloadLink in Wicket to allow a user to download a created excel file, and then to be deleted afterwards. When this is done over SSL IE gives me an error:
"Unable to download.
Internet Explorer was unable to open this site. The requested site is either unavailable or cannot be found. Please try again later. "
here:
http://support.microsoft.com/kb/323308
after doing some reading from the above microsoft support link, it seems it is because
because it's over SSL, and I have
response.setHeader("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store");
I set my downloadLink like so:
private void setupDownloadLink()
{
IModel excelFileModel = new AbstractReadOnlyModel()
{
public Object getObject()
{
return excelCreator();
}
};
auditDownloadlink = new DownloadLink("auditDownloadlink", excelFileModel);
auditDownloadlink.setOutputMarkupPlaceholderTag(true);
auditDownloadlink.setDeleteAfterDownload(true);
auditDownloadlink.setCacheDuration(Duration.NONE);
auditDownloadlink.setVisible(false);
findUserForm.add(auditDownloadlink);
}
However, it seems to work if I do: auditDownloadlink.setCacheDuration(Duration.Minute);
I guess I am confused on what is happening with this. Does the setCacheDuration mean how long after the file is created, it will be available for before it is deleted? Or does this mean how long in total the file will be available for from the start of declaring it?
inside the excelCreator() method I call File excelfile = new File("Access.xls"); and then go ahead and process all of the excel work and create the spreadsheet, then at the end of the method I call:
FileOutputStream output = new FileOutputStream(excelfile);
workbook.write(output);
output.close();
Will the duration time I set start from the moment I call File excelfile = new File("ssaUserIDAccess.xls")?
What is the best duration and setup I should use for this scenario? Because the files can get quit huge, and can take some time to create if it is big enough.
Thanks!
I do not remember the reason, but we had the same problem on SSL/IE and we just set the cache duration to 1 second that is enough. Just it cannot be NONE. Another solution we've never found.
auditDownloadlink.setCacheDuration(Duration.ONE_SECOND)
We are trying to get an image file that has been attached to a Doc in a local CouchBase-Lite.
I'd like to be able to get this files by using the same URL syntax used for the CouchDB Remote server. (Just point to local server instead of remote)(http://wiki.apache.org/couchdb/HTTP_Document_API#Attachments)
I can seem to find how to do this.
Anyone know how? Thanks
Assuming that you are actually asking about Couchbase-Lite (aka TouchDB, ie. the embedded iOS/Android SDK) then you should look here http://couchbase.github.io/couchbase-lite-ios/docs/html/interfaceCBLAttachment.html (or the Android equivalent if that's what you're working on).
I'm not sure why you're also asking about URL syntax if that's what you're doing, so I'm not sure that is what you're doing, but hey - there's your answer. You can clarify if you were talking about something else.
This is not really an answer because I'm also looking for a solution to this. I am using CBL iOS and i want to get the local database URL to be able to get info from it.
This is what i have so far :
string[] paths = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
var request = new NSMutableUrlRequest();
request.Url = new NSUrl(paths[0], false);
request.HttpMethod = "GET";
var data = NSUrlConnection.SendSynchronousRequest(request, out response, out error);
if(error != null)
{
Console.WriteLine("Error in SendRequest=" + error.LocalizedDescription);
throw new HttpRequestException(error);
}
And this prints out in the console : Error in SendRequest=The requested URL was not found on this server.
the URL is something like this :
file:///Users/ME/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/ABFDF-ADBAFB-SFGNAFAF/Documents/users/user
I want to develop a windows phone based application in which I need to put the number of files in a folder (this folder is already a part of the project) to a list so that at run time I can access those files. If anybody can give me idea of how to do that then it will be great help.
In normal WPF applications we can write code like
DirectoryInfo di = new DirectoryInfo("D:\\Tempo");
FileInfo[] fi = di.GetFiles("*", SearchOption.AllDirectories);
MessageBox.Show(fi.Length.ToString());
But Windows phone inside solution how do I do that?
I can get a single file access by this code
if (Application.GetResourceStream(new Uri("/WindowsPhone;component/Folder/file09.jpg", UriKind.Relative)) != null)
{
MessageBox.Show("Hi");
}
But inside that folder there are many files and I want to put them into list so at run time I can access those images. But the user won't be knowing about that so it should be a C# code, not a XAML code. Any help would be great.
It's pretty easy.
Make sure you add the specific folder to the Solution. Along with any files you want in that folder.
Make sure each file's Properties are set like so:
Build Action: Content
Copy to Output Directory: Do not copy
Make sure the application had loaded before calling
Lets say I had a folder called "Testfiles" and I want to read from it then:
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
ReadAllFilesFromFolder("Testfiles");
}
// TODO: recursion to get subfolders and files (maybe?)
public async void ReadAllFilesFromFolder(string folder_name)
{
var package = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await package.GetFolderAsync(folder_name);
foreach (var file in await assetsFolder.GetFilesAsync())
{
// TODO: whatever you want to do with file
// string filename = file.Name;
}
}
I have a document library setup to recieve emails. The emails coming in have a single picture and a csv file which I use for some processing.
The override emailrecieved works perfectly but of course as I override I lose the nice SharePoint functionaliy that saves the incomming email as configured in the settings.
It was my understanding that I could call MyBase.EmailRecieved in my event for the underlying functionality to still work. This however is not working and no record of the email coming in is getting retained.
For now I am explicitly creating an audit trail but I would like to rely on SharePoints existing functionality as I believe it will be more robust.
What am I doing wrong with the MyBase.EmailRecieved call? Or what can I do instead if this doesnt work?
Thanks in advance.
When writing your own EmailReceived event receiver you will loose the default functionality.
What you will have to do is to implement this default functionality yourself. Let me give you a simple example. The following example saves all mail attachments to the list if they are *.csv files. You can do the same with the emailMessage and save it to the list as well. As you can see it is as easy as to add Files.Add to add a file to a document library.
public override void EmailReceived(SPList list, SPEmailMessage emailMessage, string receiverData)
{
SPFolder folder = list.RootFolder;
//save attachments to list
foreach (SPEmailAttachment attachment in emailMessage.Attachments)
{
if (attachment.FileName.EndsWith(".csv"))
{
var attachmentFileName = attachment.FileName;
folder.Files.Add(folder.Url + "/" + attachmentFileName, attachment.ContentStream, true);
}
}
list.Update();
}