mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-02-12 19:22:45 +00:00
s3: return 0 on failure instead of null when getting attachment size
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Notesnook.API.Interfaces
|
||||
{
|
||||
Task DeleteObjectAsync(string userId, string name);
|
||||
Task DeleteDirectoryAsync(string userId);
|
||||
Task<long?> GetObjectSizeAsync(string userId, string name);
|
||||
Task<long> GetObjectSizeAsync(string userId, string name);
|
||||
string GetUploadObjectUrl(string userId, string name);
|
||||
string GetDownloadObjectUrl(string userId, string name);
|
||||
Task<MultipartUploadMeta> StartMultipartUploadAsync(string userId, string name, int parts, string uploadId = null);
|
||||
|
||||
@@ -137,14 +137,14 @@ namespace Notesnook.API.Services
|
||||
throw new Exception("Could not delete directory.");
|
||||
}
|
||||
|
||||
public async Task<long?> GetObjectSizeAsync(string userId, string name)
|
||||
public async Task<long> GetObjectSizeAsync(string userId, string name)
|
||||
{
|
||||
var url = this.GetPresignedURL(userId, name, HttpVerb.HEAD, S3ClientMode.INTERNAL);
|
||||
if (url == null) return null;
|
||||
if (url == null) return 0;
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Head, url);
|
||||
var response = await httpClient.SendAsync(request);
|
||||
return response.Content.Headers.ContentLength;
|
||||
return response.Content.Headers.ContentLength ?? 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user