private static string GetResourceUrlInternal(IStorageProviderSession session, String path)
 {
     if (session is DropBoxStorageProviderSession)
     {
         var    dbSession = session as DropBoxStorageProviderSession;
         String uri       = PathHelper.Combine(dbSession.SandBoxMode
                                             ? GetUrlString(DropBoxSandboxRoot, session.ServiceConfiguration)
                                             : GetUrlString(DropBoxDropBoxRoot, session.ServiceConfiguration),
                                               HttpUtilityEx.UrlEncodeUTF8(path));
         return(uri);
     }
     return(null);
 }
示例#2
0
        public static string GetCommitUploadSessionUrl(IStorageProviderSession session, IResumableUploadSession uploadSession)
        {
            var rUploadSession = uploadSession as ResumableUploadSession;

            if (rUploadSession == null)
            {
                throw new ArgumentNullException("uploadSession");
            }

            return(GetUrlString(DropBoxCommitChunkedUpload, session.ServiceConfiguration)
                   + "/" + GetRootToken((DropBoxStorageProviderSession)session)
                   + "/" + HttpUtilityEx.UrlEncodeUTF8(DropBoxResourceIDHelpers.GetResourcePath(null, rUploadSession.FileName, rUploadSession.ParentId)));
        }
示例#3
0
        public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, string Name, ICloudDirectoryEntry parent)
        {
            // build url
            String uriString = GetResourceUrlInternal(session, parent);

            if (!Name.Equals("/") && Name.Length > 0)
            {
                uriString = PathHelper.Combine(uriString, HttpUtilityEx.UrlEncodeUTF8(Name));
            }

            // request the data from url
            int code;
            var res = DropBoxRequestParser.RequestResourceByUrl(uriString, this, session, out code);

            // check error
            if (res.Length == 0)
            {
                if (code != (int)HttpStatusCode.OK)
                {
                    HttpException hex = new HttpException(Convert.ToInt32(code), "HTTP Error");

                    throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList, hex);
                }
                else
                {
                    throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList);
                }
            }

            // build the entry and subchilds
            BaseFileEntry entry = DropBoxRequestParser.CreateObjectsFromJsonString(res, this, session);

            // check if it was a deleted file
            if (entry.IsDeleted)
            {
                return(null);
            }

            // set the parent
            entry.Parent = parent;

            // go ahead
            return(entry);
        }
示例#4
0
        public override string GetResourceUrl(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry, String additionalPath)
        {
            // get the dropbox session
            DropBoxStorageProviderSession dbSession = session as DropBoxStorageProviderSession;

            // build the internal url
            String url = GetResourceUrlInternal(session, fileSystemEntry);

            // add the optional path
            if (additionalPath != null)
            {
                url = PathHelper.Combine(url, HttpUtilityEx.UrlEncodeUTF8(additionalPath));
            }

            // generate the oauth url
            OAuthService svc = new OAuthService();

            return(svc.GetProtectedResourceUrl(url, dbSession.Context, dbSession.SessionToken as DropBoxToken, null, WebRequestMethodsEx.Http.Get));
        }
        public static String GetDownloadFileUrlInternal(IStorageProviderSession session, ICloudFileSystemEntry entry)
        {
            // cast varibales
            var dropBoxSession = session as DropBoxStorageProviderSession;

            // gather information
            var rootToken   = GetRootToken(dropBoxSession);
            var dropboxPath = DropBoxResourceIDHelpers.GetResourcePath(entry);

            // add all information to url;
            var url = GetUrlString(DropBoxUploadDownloadFile, session.ServiceConfiguration) + "/" + rootToken;

            if (dropboxPath.Length > 0 && dropboxPath[0] != '/')
            {
                url += "/";
            }

            url += HttpUtilityEx.UrlEncodeUTF8(dropboxPath);

            return(url);
        }
 public static String GetCommitUploadSessionUrl(IStorageProviderSession session, IResumableUploadSession uploadSession)
 {
     return(GetUrlString(DropBoxCommitChunkedUpload, session.ServiceConfiguration)
            + "/" + GetRootToken((DropBoxStorageProviderSession)session)
            + "/" + HttpUtilityEx.UrlEncodeUTF8(DropBoxResourceIDHelpers.GetResourcePath(uploadSession.File.Parent, uploadSession.File.Name)));
 }
示例#7
0
        private string GetResourceUrlInternal(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry)
        {
            // cast varibales
            DropBoxStorageProviderSession dropBoxSession = session as DropBoxStorageProviderSession;

            // build the path for resource
            String resourcePath = GenericHelper.GetResourcePath(fileSystemEntry);

            // trim heading and trailing slashes
            resourcePath = resourcePath.TrimStart('/');
            resourcePath = resourcePath.TrimEnd('/');

            // build the metadata url
            String getMetaData;

            // get url
            if (dropBoxSession.SandBoxMode)
            {
                getMetaData = PathHelper.Combine(GetUrlString(DropBoxSandboxRoot, session.ServiceConfiguration), HttpUtilityEx.UrlEncodeUTF8(resourcePath));
            }
            else
            {
                getMetaData = PathHelper.Combine(GetUrlString(DropBoxDropBoxRoot, session.ServiceConfiguration), HttpUtilityEx.UrlEncodeUTF8(resourcePath));
            }

            return(getMetaData);
        }