/** * Construct a LFS repository storing large objects in Amazon S3 * * @param config * AWS S3 storage bucket configuration */ public S3Repository(S3Config config) { validateConfig(config); this.s3Config = config; }
/** {@inheritDoc} */ @Override public Response.Action getUploadAction(AnyLongObjectId oid, long size) { cacheObjectMetaData(oid, size); URL objectUrl = getObjectUrl(oid); Map<String, String> headers = new HashMap<>(); headers.put(X_AMZ_CONTENT_SHA256, oid.getName()); headers.put(HDR_CONTENT_LENGTH, Long.toString(size)); headers.put(X_AMZ_STORAGE_CLASS, s3Config.getStorageClass()); headers.put(HttpSupport.HDR_CONTENT_TYPE, "application/octet-stream"); //$NON-NLS-1$ headers = SignerV4.createHeaderAuthorization(s3Config, objectUrl, METHOD_PUT, headers, oid.getName()); Response.Action a = new Response.Action(); a.href = objectUrl.toString(); a.header = new HashMap<>(); a.header.putAll(headers); return a; }
@Override public Response.Action getDownloadAction(AnyLongObjectId oid) { URL endpointUrl = getObjectUrl(oid); Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put(X_AMZ_EXPIRES, Integer.toString(s3Config.getExpirationSeconds())); Map<String, String> headers = new HashMap<String, String>(); String authorizationQueryParameters = SignerV4.createAuthorizationQuery( s3Config, endpointUrl, METHOD_GET, headers, queryParams, UNSIGNED_PAYLOAD); Response.Action a = new Response.Action(); a.href = endpointUrl.toString() + "?" + authorizationQueryParameters; //$NON-NLS-1$ return a; }
private void validateConfig(S3Config config) { assertNotEmpty(LfsServerText.get().undefinedS3AccessKey, config.getAccessKey()); assertNotEmpty(LfsServerText.get().undefinedS3Bucket, config.getBucket()); assertNotEmpty(LfsServerText.get().undefinedS3Region, config.getRegion()); assertNotEmpty(LfsServerText.get().undefinedS3SecretKey, config.getSecretKey()); assertNotEmpty(LfsServerText.get().undefinedS3StorageClass, config.getStorageClass()); }
private URL getObjectUrl(AnyLongObjectId oid) { try { return new URL(String.format("https://s3-%s.amazonaws.com/%s/%s", //$NON-NLS-1$ s3Config.getRegion(), s3Config.getBucket(), getPath(oid))); } catch (MalformedURLException e) { throw new IllegalArgumentException(MessageFormat.format( LfsServerText.get().unparsableEndpoint, e.getMessage())); } }
@Override public Response.Action getUploadAction(AnyLongObjectId oid, long size) { cacheObjectMetaData(oid, size); URL objectUrl = getObjectUrl(oid); Map<String, String> headers = new HashMap<String, String>(); headers.put(X_AMZ_CONTENT_SHA256, oid.getName()); headers.put(HDR_CONTENT_LENGTH, Long.toString(size)); headers.put(X_AMZ_STORAGE_CLASS, s3Config.getStorageClass()); headers.put(HttpSupport.HDR_CONTENT_TYPE, "application/octet-stream"); //$NON-NLS-1$ headers = SignerV4.createHeaderAuthorization(s3Config, objectUrl, METHOD_PUT, headers, oid.getName()); Response.Action a = new Response.Action(); a.href = objectUrl.toString(); a.header = new HashMap<>(); a.header.putAll(headers); return a; }
/** {@inheritDoc} */ @Override public Response.Action getDownloadAction(AnyLongObjectId oid) { URL endpointUrl = getObjectUrl(oid); Map<String, String> queryParams = new HashMap<>(); queryParams.put(X_AMZ_EXPIRES, Integer.toString(s3Config.getExpirationSeconds())); Map<String, String> headers = new HashMap<>(); String authorizationQueryParameters = SignerV4.createAuthorizationQuery( s3Config, endpointUrl, METHOD_GET, headers, queryParams, UNSIGNED_PAYLOAD); Response.Action a = new Response.Action(); a.href = endpointUrl.toString() + "?" + authorizationQueryParameters; //$NON-NLS-1$ return a; }
private void validateConfig(S3Config config) { assertNotEmpty(LfsServerText.get().undefinedS3AccessKey, config.getAccessKey()); assertNotEmpty(LfsServerText.get().undefinedS3Bucket, config.getBucket()); assertNotEmpty(LfsServerText.get().undefinedS3Region, config.getRegion()); assertNotEmpty(LfsServerText.get().undefinedS3SecretKey, config.getSecretKey()); assertNotEmpty(LfsServerText.get().undefinedS3StorageClass, config.getStorageClass()); }
private URL getObjectUrl(AnyLongObjectId oid) { try { return new URL(String.format("https://s3-%s.amazonaws.com/%s/%s", //$NON-NLS-1$ s3Config.getRegion(), s3Config.getBucket(), getPath(oid))); } catch (MalformedURLException e) { throw new IllegalArgumentException(MessageFormat.format( LfsServerText.get().unparsableEndpoint, e.getMessage())); } }
@Override public long getSize(AnyLongObjectId oid) throws IOException { URL endpointUrl = getObjectUrl(oid); Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put(X_AMZ_EXPIRES,
/** * Construct a LFS repository storing large objects in Amazon S3 * * @param config * AWS S3 storage bucket configuration */ public S3Repository(S3Config config) { validateConfig(config); this.s3Config = config; }
URL endpointUrl = getObjectUrl(oid); Map<String, String> queryParams = new HashMap<>(); queryParams.put(X_AMZ_EXPIRES,