So I'm PUTing a file onto one drive, my URI looks like
https://apis.live.net/v5.0/me/skydrive/files/?access_token=12345
however, if I try and change the folder to, say, Documents:
https://apis.live.net/v5.0/me/skydrive/files/Documents?access_token=12345
or
https://apis.live.net/v5.0/me/skydrive/Documents/files?access_token=12345
I'll get a HTTP 400 (bad request error).
One "workaround" could be to query the top level directory of the onedrive, done by reading the JSON response from the first URI about, and then suck out the upload_location for a desired folder, however I feel this is a bit long winded. From the Upload a File section in
https://msdn.microsoft.com/en-us/library/dn659726.aspx
I got the impression I should be able to specify a friendly folder path.
I'm positive it's a really simple answer, but I've wasted long enough on it and hopefully this will serve as a resource for those having the same issue (haven't been able to find elsewhere except for an unanswered question here http://answers.microsoft.com/en-us/onedrive/forum/sdfiles-sdupload/how-to-upload-a-file-to-a-specific-folder-created/0d57e43c-a3ec-42fc-b3b7-f15a17b2836f)
Thanks
Based on your examples I think you just need to change Documents -> my_documents and then the scenario will work like you'd want. Here is the relative excerpt from the documentation.
Use friendly names to access certain OneDrive folders
To access certain OneDrive folders, you can use friendly names instead of folder IDs. Use the following friendly names to access these corresponding folders in the OneDrive UI:
USER_ID/skydrive/camera_roll represents the OneDrive camera roll folder.
USER_ID/skydrive/my_documents represents the Documents folder.
USER_ID/skydrive/my_photos represents the Pictures folder.
USER_ID/skydrive/public_documents represents the Public folder.
In each case, replace USER_ID with either me for the signed-in user or a user ID for any other consenting user.
For example, to read the Documents folder's properties, use a REST API call to the folder's ID, like this.
GET https://apis.live.net/v5.0/folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!110?access_token=ACCESS_TOKEN
Try the API's listed in the following link:
https://dev.onedrive.com/README.htm#
These work fine for me.
Related
If I were to follow this example file uploads would be stored in the wwwroot file. It is my understanding this file is where you should store static files that will be served to the user. Sure, I want my users to be able to download but is there a filesystem, specific to asp.net core/IIS/Windows Server 2012, that would be best? I'm expecting around 10,000 files max after several years.
I'm planning on creating a folder for the uploaded documents, I'm just unsure of where to place it.
Note: The answer provided here was not sufficient
To the best of my understanding, unless you take special precautions, files under wwwroot can be downloaded freely by users, bots, etc. with no authentication. If the files are not sensitive in nature, then there is nothing wrong with using wwwroot.
If you want to provide security at the controller level (e.g., a user can only view their own files), then it's probably better to put them elsewhere in the file system. The path is kind of arbitrary, but the security settings on the folder must be set in such a way that the dotnet process can access it. You can give Everyone full access, or be more restrictive if you see fit. This is done directly on the OS of the server, assuming that you have access to it.
For 2 reasons I would not do that.
1. Keep control and overview. I would create a subfolder and give it the needed rights to create and write uploaded files there.
2. You are then free to change authorization if your requirements ever should change.
I've been trying to learn how to handle saving normal .txt files in UWP, and have realized that it's quite locked down compared to WPF, especially in the sense of what folders you can access without requesting the user to select a location. I have searched for various ways this might be possible but found no working answer.
Question Description:
I basically would love to know if this is possible, and preferably a point in the direction where I can learn how exactly to do this.
Application settings page requires user to select folder where files are saved.
Application remembers this between launches (unsure if this is possible, but I can't require the user to select the folder on every launch)
Application saves files to the specified folder.
In my understanding, this should be possible, as the user is the one specifying the location via filepicker, but is it possible to have this work between launches so that the user wont be required to re-select the save folder?
I need to figure this out, as I would like my application to support selecting attached network drives, cloud storage folders, etc.
Any help is very much appreciated, and if there are any questions I will answer them to the best of my ability.
Fow this purpose there are two access lists designed: FutureAccessList and MostRecentlyUsedList. Once the user has picked up the folder with the picker, you add it to such list and receive a token, which you save for future purpose in LocalSettings:
ApplicationData.Current.LocalSettings.Values["MyFolder"] = StorageApplicationPermissions.FutureAccessList.Add(pickedFolder);
Then later, once you want to access that folder, you can do it like this:
StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(ApplicationData.Current.LocalSettings.Values["MyFolder"].ToString());
You can't save a StorageFolder or a path to it in settings, hence the UWP app needs permissions to access the folder. Using above access lists solves this problem.
I believe you want to save user settings and keep it somewhere so that next time when they launch the application, they can use the same settings.
Please check out this tutorial from Microsoft, which describes how to do exactly that.
https://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx
im working on a project where in i need to populate some files from the server and show them in a webrowser to the user. Where user would be allowed to do basic CRUD operation on the file
The problem is that i cannot assign the name of the file/folder as unique id which i need in case a user deletes/renames a file i should be able to identify the file later.
My question is that is there anything unique about any file/folder in NTFS that is unique about them and that can be used? and how that information can be accessed using .NET c#.
Came across the BY_HANDLE_FILE_INFORMATION structure but it probably needs me to pinvoke.
UPDATE 1 - tried looking at the feasibility to use nFileIndexHigh and nFileIndexLow but they would need me to do a pinvoke and also this method cannot be used with folders
one link when they mention folders Unique Folder Identifier tells me that it isnt possible.
Disregarding the fact that it seems that you don't want to P/Invoke a different approach could be to use the Windows Shell API. This API has the concept of a PIDL which identifies a folder (or "similar" item) in the shell namespace. A PIDL does not change even if the user renames the folder. The drawback is that the Shell API exposes what you see in Windows Explorer, e.g. Desktop is at the root of the hierarchy even though it physically is subfolder somewhere on a disk.
I think the FILE_INTERNAL_INFORMATION structure, used to query for the file system's 8-byte file reference number for a file, is what you need. The IndexNumber is a number that uniquely identifies a file. You should use P/invoke to query this information.
I am using asp.net mvc and have a section where a user can upload images. I am wondering where should I store them.
I was following this tutorial and he seems to store it in the app_data. I however read another person say it should only hold your database.
So not sure what the advantages are for using app_data. I am on a shared hosting so I don't know if that makes a difference.
Edit
I am planning to store the path to the images in the database. I will be then using them in a image tag and rendering them to the user when they come to my site. I have a file uploader that only will expect images(check will be client and server)
The tutorial is a simple example - and if you read the comments, the original code just saved to an uploads directory, no app_data in sight.
It was changed to app_data because that's a special folder - one that will not allow execution of code.
And you have understood correctly - app_data is really there for holding file based databases. That's the meaning of the folder. As such saving images into it doesn't feel like the right thing to do.
If you are certain only images will get uploaded (and you control that), I would suggest an /uploads directory - a reserved location for images that also will not allow code execution (something that you should be able to control via IIS).
I would say that depends on what you will do with that images later. If you use those images in an img tag, you could save them somewhere in the Content/ folder structure.
If you do not need them reachable from the outside, or need to stream them changed back, you might store them out of the web root if the hoster allows for that.
I wouldn't store them in app_data, as I - personally - think that it's more a convention to store there a database. Most developers not familiar with that product wouldn't look there for the image.
But: you could store binaries in a db (even though it is probably not the best thing to do), so a reference in a db pointing to a file in the same directory makes sense again.
It's more an opinion thing than a technical question though, I think.
I prefer to store them in the database. When storing images on the file system I've found it can be a bit harder to manage them. With a database you can quickly rename files, delete them, copy them, etc. You can do the same when they're on the file system, but it takes some scripting knowledge.
Plus I prefer not to manage paths and file locations, which is another vote for the database. Those path values always make their way into the web.config and it can become more difficult to deploy and manage.
I have recently been assigned a task which sounded relatively simple!
Upon attempting it became clear it wasn't as straight forward as i first imagined!!!
I am trying to download multiple files to one location on the users machine. They select these files from lists within a custom share-point web part. Thats the bit i have managed to get working! The downloading is done via WebClient (System.Net.WebClient)
I now want to allow the user to select a location on their local machine to download the files to.
I thought i would be able to use but after attempting this i realized i can only pick files :( in order to get the desired location which will confuse the user
I want something similar to the above but i only need it to return a path location like c:\Temp or any other location the user prefers on their local machine.
Could anyone suggest a control that could provide this functionality. It can also be a share-point control.
In the meantime I will be attempting Tree view as i have never used these before and these may have the power to do this from what i have read
Cheers
Truez
Clarity on language ASP.NET
Unfortunately, you can't do this without some kind of active content, like a Flash control or spit activeX /spit.
It seems strange at first, but you have to consider that this kind of functionality would let a site discover the structure of anyones storage devices; this is not 'a good thing'™
However, perhaps a different approach might solve the problem?
Why are you using WebClient, can't you provide the link to the client and let them choose their own download folder ?
I ended up zipping the files in to one folder and passed the file to be downloaded through the browser! Thanks for your comments!