简体   繁体   中英

OneDrive API upload file as public

I am uploading a file to OneDrive using JavaScript API.

<script>
$('#file-to-save').change(function(){
console.log ("Uploading");
fileaddress = $('#file-to-save').val();
var folder_id = 'folder.1d67c8c08569256a.1D67C8C08569256A!36156';
console.log(folder_id);
WL.upload({
    path: folder_id,
    element: 'file-to-save',
    overwrite: 'rename'
}).then(
    function(response) {
        // Handle the response
        $('#status').html("Upload complete. Getting shared link...");
        // TODO: Get the file id
        var file_id = response.id;
        getSharedLink(file_id);
    },
    function(error) {
        console.log("Error");
        $('#status').html(error.error.message);
          }
);
});
</script>

The problem is that file uploads as private, and users need to login to their MS account in order to view it. Is it possible to change privacy to Public via API?

The only sharing available through the OneDrive developer APIs today is generation of read/edit/embed sharing links: http://msdn.microsoft.com/en-us/library/dn659731.aspx#get_links_to_files_and_folders

If a user uses the generated link to view the item, they do not need to sign in. Unfortunately, this is limiting since a person has to use the link to access the item and it doesn't cover the full range of OneDrive sharing scenarios available via the website.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM