DropNet returning metadata for root folder not folder requested - dropnet

Problem: GetMetaData for the folder that I need returns the root folder metadata.
Background:
I'm trying to write a small app to download a folder that is too large (many thousand files and multiple GB) to download from the Dropbox web interface. It tries to recurse through the subdirectories of the directory given, downloading all the files.
What actually happens is an endless loop. The app (incorrectly) gets the root folder metadata, iterates through the directories until it hits the directory I need and then starts working through the root directory as that is the metadata set that it receives.
The directory name "/Apps" works fine but the one I need doesn't. The folder name has an underscore and a mix of upper and lower case letters (no other characters) similar to "/XYX_DataFolder".
My app has "Full Dropbox" permission and I authorized with the account that the api key was acquired under.
Changing the directory name is not an option for me.
I'm using VS2012 and the DropNet was added through NuGet.
Any input on this issue would be welcome. Thanks!
Edit:
Runtime Version v4.0.30319
Version 1.10.23.0
As reported in the Visual Studio properties page for the reference.
I authorize which works fine and then use the code below. Some directories work fine but when I try to GetMetaData on the folder mentioned above, I get the metadata from the root folder.
private void DownloadDirectory( string serverDirectory, string clientDirectory ) {
var meta = m_client.GetMetaData( serverDirectory, false, false );
foreach ( var item in meta.Contents ) {
var destinationPath = Path.Combine( clientDirectory, item.Name );
if ( item.Is_Dir && item.Path == m_serverRootDirectory ) {
DownloadDirectory( item.Path, destinationPath );
}
else {
//var fileBytes = m_client.GetFile( item.Path );
//File.WriteAllBytes( destinationPath, fileBytes );
//textBox1.Text += Environment.NewLine + destinationPath;
}
}
}

Ok, so I downloaded the source and found my problem right away. I was missing a null for the hash in the GetMetaData call, so it was using the wrong overload. Sorry to waste your time... Thanks for the response!

Related

sg-cookie-optin extension throws No class named SGalinski\SgCookieOptin\Hook\LicenceCheckHook

Downloaded this https://packagist.org/packages/sgalinski/sg-cookie-optin
Copied the file to the server, activated the extension in ext manager.
Suddenly front & backend not working anymore.
Deleted the extension manually from PackageStates.php according to
https://docs.typo3.org/m/typo3/guide-installation/master/en-us/ExtensionInstallation/Index.html
Frontend now working, backend still throws the error
No class named SGalinski\SgCookieOptin\Hook\LicenceCheckHook
in /home/sc/wwn/typo3_src-10.4.10/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 3340
throw new \InvalidArgumentException($errorMsg, 1294585865);
}
} else {
$errorMsg = 'No class named ' . $parts[0];
throw new \InvalidArgumentException($errorMsg, 1294585866);
}
} elseif (function_exists($funcName) && is_callable($funcName)) {
// It's a function
$content = call_user_func_array($funcName, [&$params, &$ref]);
I did set up the key and the output folder in the config file
what I didn't do since backend not working anymore :
3. Add the static TypoScript named "Cookie Optin" to your instance with the "Template" backend module.
Open up the "Template" module in the backend of TYPO3.
Go to your root site page within the page tree.
Choose "Info/Modify" at the select on the top.
Click on the button "Edit the whole template record".
Select the tab "Includes".
Choose the template "Cookie Optin (sg_cookie_optin)" on the multi select box with the name "Include static (from extensions)"
Save
4. Go into the "Cookie Opt In" backend module, configure it and save it once.
Any idea how i can fix that? Pretty stuck atm.
The install tool of your installation should still work. Try to open yourdomain.tld/typo3/install.php.
To enable the Install Tool, the file ENABLE_INSTALL_TOOL must be created in the directory typo3conf/. Make sure that the file has no file extension like .txt.
Then log in to the install tool and go to Maintenance => Flush TYPO3 and PHP Cache and flush all caches.
Then the backend should work.
If the install tool is not accessible, try to find a folder var/Cache. Most probably it will be located in typo3temp. Delete all files and subfolders from the Cache folder.

SmtpClient.send - Could not find a part of the path

I'm trying to write an email to my local folder. I successfully wrote an email to my documents folder using this code:
using (var client = new SmtpClient())
{
client.UseDefaultCredentials = true;
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = tempDocsPath;
client.Send(message);//Writes to the PickupDirectoryLocation
}
However, when I ported this same code to another project, it gives me this error:
System.Net.Mail.SmtpException : Failure sending mail. ---> System.IO.DirectoryNotFoundException : Could not find a part of the path 'C:\Users\josh.bowdish\source\repos\GenerateEmail\GenerateEmail\bin\Debug\net461\tempFiles\AAMkAGUyODNhN2JkLThlZWQtNDE4MS1hODM1LWU0ZDY4Y2NhYmMxOQBGAAAAAABKB1jlHZSIQZSWN7AYZH2SBwDZdOTdKcayQ5NMwcwkNT7UAAAAAAEMAADZdOTdKcayQ5NMwcwkNT7UAACn\0a5b24a5-d625-4ecd-9990-af5654679820.eml'.
I've verified that the directory it's trying to write to exists, even rewrote it to look like this:
private static string WriteEmail(MailMessage message, string messageDirectory)
{
if (Directory.Exists(messageDirectory))
{
using (var client = new SmtpClient())
{
client.UseDefaultCredentials = true;
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = messageDirectory;
client.Send(message);//Writes to the PickupDirectoryLocation
}
...
}
//stuff that returns the full email path
}
It breaks on the client.Send() line with the above error. As far as I can tell the code paths are identical. I've tried writing to the same folder that the other project is working with to no avail. The only thing I can think of is it's trying to write the email file before it exists, but the other project is writing it just fine.
Can someone tell me what is generating this error?
Thanks,
~Josh
This could be a permissions problem. Ensure that the account that your application is running under has permissions to "write" to this directory. Your Directory.Exists could be passing since it is only checking if the directory is there, but failing when trying to actually write to it.

Get access to wwwroot folder in AWS Elastic Beanstalk .net core application

For the last couple days I've been trying to figure out the best way to store images for my EB .net core project. When I initially developed it, I just stored the images in the wwwroot/images/{whatever I needed} directories. However, I found shortly after deployment, that the project does not have permission to write (and probably read, no way of knowing yet) that folder.
The specific error message I get is "Access to the path 'C:\\inetpub\\AspNetCoreWebApps\\app\\wwwroot\\images' is denied
I've tried integrating AWS's EFS, but I can't seem to figure that out either. I added the storage-efs-mountfilesystem.config file that's mentioned in the AWS EB EFS documentation, but to no avail. Not only do I not have access to any folder named /efs, I'm not even sure that's the right path.
About the only available option I see is storing all the images as blobs in the DB, which I'd really rather avoid.
I've tried gaining access to the wwwroot folder using this answer here, but there doesn't seem to be any change in the response I'm getting.
I'm under contract, and need this up and working sooner, rather than later. If I must, I'll go the db route, but it's hardly a long term option. Although it is a small application, and for the foreseeable future will only have one active user.
The code for the file upload just in case you need it is below:
[Route("Image"), HttpPost()]
public async Task<ResponseInfo> SaveImage()
{
try
{
var file = Request.Form.Files.FirstOrDefault();
if (file != null && file.Length > 0)
{
if (file.Length > _MaxFileSize)
{
return ResponseInfo.Error($"File too large. Max file size is { _MaxFileSize / (1024 * 1024) }MB");
}
var extension = Path.GetExtension(file.FileName).ToLower();
if (extension == ".png" || extension == ".jpg" || extension == ".jpeg" || extension == ".gif")
{
var filename = String.Concat(DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss"), extension);
var basePath = Path.Combine(_Env.WebRootPath, "images", "tmp");
if (Directory.Exists(basePath) == false)
{
Directory.CreateDirectory(basePath);
}
using (var inputStream = new FileStream(Path.Combine(basePath, filename), FileMode.Create))
{
try
{
await file.CopyToAsync(inputStream);
return ResponseInfo.Success(filename);
}
catch (Exception ex)
{
ex.Log();
return ResponseInfo.Error("Failed to save image");
}
}
}
else
{
return ResponseInfo.Error($"File type not accepted. Only PNG, JPG/JPEG, and gif are allowed");
}
}
}
catch (Exception ex) {
return ResponseInfo.Error(ex.Message);
}
return ResponseInfo.Error("No files received.");
}
If it matters, I'm running the latest VS 2017 Community. Publishing to aws using AWS Toolkit for Visual Studio 2017 V1.14.4.1.
I may be late but this might help others. However, we were not able to access the wwwroot but we made a new directory and made changes to our code to access files from that path.
We have added a folder to our project .ebextensions and under that we have added a file dirAccess.config (name can be different)
dirAccess.conifg
commands:
0_:
command: 'if not exist "C:\\inetpub\\assets" mkdir C:\\inetpub\\assets'
1_:
command: 'icacls "C:\\inetpub\\assets" /grant "IIS APPPOOL\DefaultAppPool:(OI)(CI)F"'
2_:
command: 'icacls "C:\\inetpub\\assets"'
Please make sure that this folder (.ebextensions) is included in the publish zip.
To include the folder in publish, need to add below lines to .csproj
<ItemGroup>
<None Include=".ebextensions\alarms.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include=".ebextensions\assetsDirectory.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

Power Query : How to handle "DataSource.NotFound: File or Folder: We couldn't find the folder " error

I'm trying to get the folder contents using the query below and also handles the error. But still I'm getting the text with a warning icon - "DataSource.NotFound: File or Folder: We couldn't find the folder"
See the M-code below:
let
Source = Folder.Files("\\serverpath\Desktop\"),
AlternativeOutput=#table(type table [Name=text,Extension=text,Availability=text], {{"Error", "Error", "Folder not available"}}),
TestForError= try Source,
Output =
if TestForError[HasError] then AlternativeOutput
else Source
in
Output
This is likely a bug, which explains why try...otherwise also doesn't work. The HasError field is returning false even though we get a DataSource.NotFound error. I've filed an item on our end to track this issue.
You need to force evaluation of the Folder.Files at each try / otherwise attempt, using Table.Buffer
= try Table.Buffer(Folder.Files(path1)) otherwise Folder.Files(path2)
you can then evaluate multiple paths, such as the same onedrive account if used on different computers having different login credentials i.e named username on one pc, but user.name on another (e.g personal computer, work computer)
= let SourceA = try Folder.Files("C:\Users\Username\OneDrive\Documents\"),
SourceB = try Folder.Files("C:\Users\User.name\OneDrive\Documents\"),
DynamicSource = try Table.Buffer(SourceA[Value])
otherwise Table.Buffer(SourceB[Value])
in DynamicSource 

Adding a File object programatically in Plone using PloneFormGen

I'm writing a PloneFormGen custom action adapter in order to add a File object to a folder from the File Field in the form. Here is the script:
target = context.filefolder
form = request.form
uid = str(DateTime().millis())
target.invokeFactory("File", id=uid, file=form['arquivo-do-cv_file'])
obj = target[uid]
"filefolder" is the name of a folder inside the parent folder for the PFG FormFolder. This script is configured to run with a Manager proxy role.
Problem is that the File objects created this way won't show the "Click here to download the file" link when I view them. The files can be downloaded though, if I suppress the "/view" part from the end of the URL. What am I missing when calling invokeFactory to create the File object?
UPDATE: What I meant is that I don't get the "filename - filetype, size in KBs (size in bytes)" link for the document, below the byline. When I create a File object using the normal Plone UI, it does show up.
I suspect nothing; I think that is the default behavior in Plone 4.
I just added a File and I don't see any "Click here to download the file".
And a quick search does not reveal the string "click here to download":
aclark#Alex-Clarks-MacBook-Pro:~/Developer/test-4.1/ > grep -ir "Click here to download" parts/omelette
parts/omelette/plone/app/jquerytools/browser/jquery.tools.plugins.js: (root.tagName == 'A' ? "<p>Click here to download latest version</p>" :
parts/omelette/plone/app/jquerytools/browser/jquery.tools.plugins.min.js:" or greater is required</h2><h3>"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"</h3>"+(a.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+k+"'>here</a></p>");if(a.tagName=="A")a.onclick=function(){location.href=k}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string")a.innerHTML=d}}if(i)window[b.id]=document.getElementById(b.id);f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},
I don't have a Plone instance to test it, but try to call processForm() after invokeFactory. It will:
unmark creation flag;
rename object according to title;
reindex the object;
invoke the after_creation script and fire the ObjectInitialized event.
These actions are detailed on Object Construction Lifecycle. Maybe some of these actions are needed to create the KB information you're after (I'm hoping it's the index).